JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> } } catch (SecurityException e) { // 17-Sep-2015, tatu: Anything we could/should do here? } catch (NoSuchFieldException e) { // 17-Sep-2015, tatu: should not really happen. But... can we do anything? } return value.name(); } @Override // since 2.7 public String[] findEnumValues(Class<?> enumType, Enum<?>[] enumValues, String[] names) { HashMap<String,String> expl = null; for (Field f : ClassUtil.getDeclaredFields(enumType)) { if (!f.isEnumConstant()) { continue; } JsonProperty prop = f.getAnnotation(JsonProperty.class); if (prop == null) { continue; } String n = prop.value(); if (n.isEmpty()) { continue; } if (expl == null) { expl = new HashMap<String,String>(); } expl.put(f.getName(), n); } // and then stitch them together if and as necessary if (expl != null) { for (int i = 0, end = enumValues.length; i < end; ++i) { String defName = enumValues[i].name(); String explValue = expl.get(defName); if (explValue != null) { names[i] = explValue; } } } return names; } /** * Finds the Enum value that should be considered the default value, if possible. * <p> * This implementation relies on {@link JsonEnumDefaultValue} annotation to determine the default value if present. * * @param enumCls The Enum class to scan for the default value. * @return null if none found or it's not possible to determine one. * @since 2.8 */ @Override public Enum<?> findDefaultEnumValue(Class<Enum<?>> enumCls) { return ClassUtil.findFirstAnnotatedEnumValue(enumCls, JsonEnumDefaultValue.class); } /* /********************************************************** /* General class annotations /********************************************************** */ @Override public PropertyName findRootName(AnnotatedClass ac) { JsonRootName ann = _

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>ValueId(AnnotatedMember m) { JacksonInject.Value v = findInjectableValue(m); return (v == null) ? null : v.getId(); } @Override public Class<?>[] findViews(Annotated a) { JsonView ann = _findAnnotation(a, JsonView.class); return (ann == null) ? null : ann.value(); } @Override // since 2.7 public AnnotatedMethod resolveSetterConflict(MapperConfig<?> config, AnnotatedMethod setter1, AnnotatedMethod setter2) { Class<?> cls1 = setter1.getRawParameterType(0); Class<?> cls2 = setter2.getRawParameterType(0); // First: prefer primitives over non-primitives // 11-Dec-2015, tatu: TODO, perhaps consider wrappers for primitives too? if (cls1.isPrimitive()) { if (!cls2.isPrimitive()) { return setter1; } } else if (cls2.isPrimitive()) { return setter2; } if (cls1 == String.class) { if (cls2 != String.class) { return setter1; } } else if (cls2 == String.class) { return setter2; } return null; } /* /********************************************************** /* Annotations for Polymorphic Type handling /********************************************************** */ @Override public TypeResolverBuilder<?> findTypeResolver(MapperConfig<?> config, AnnotatedClass ac, JavaType baseType) { return _findTypeResolver(config, ac, baseType); } @Override public TypeResolverBuilder<?> findPropertyTypeResolver(MapperConfig<?> config, AnnotatedMember am, JavaType baseType) { /* As per definition of @JsonTypeInfo, should only apply to contents of container * (collection, map) types, not container types themselves: */ // 17-Apr-2016, tatu: For 2.7.4 make sure ReferenceType also included if (baseType.isContainerType() || baseType.isReferenceType()) { return null; } // No per-member type overrides (yet) return _findTypeResolver(config, am, baseType); } @Override public TypeResolverBuilder

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> new VirtualAnnotatedMember(ac, ac.getRawType(), propName.getSimpleName(), type); // and with that and property definition SimpleBeanPropertyDefinition propDef = SimpleBeanPropertyDefinition.construct(config, member, propName, metadata, prop.include()); Class<?> implClass = prop.value(); HandlerInstantiator hi = config.getHandlerInstantiator(); VirtualBeanPropertyWriter bpw = (hi == null) ? null : hi.virtualPropertyWriterInstance(config, implClass); if (bpw == null) { bpw = (VirtualBeanPropertyWriter) ClassUtil.createInstance(implClass, config.canOverrideAccessModifiers()); } // one more thing: give it necessary contextual information return bpw.withConfig(config, ac, propDef, type); } /* /********************************************************** /* Serialization: property annotations /********************************************************** */ @Override public PropertyName findNameForSerialization(Annotated a) { JsonGetter jg = _findAnnotation(a, JsonGetter.class); if (jg != null) { return PropertyName.construct(jg.value()); } JsonProperty pann = _findAnnotation(a, JsonProperty.class); if (pann != null) { return PropertyName.construct(pann.value()); } if (_hasOneOf(a, ANNOTATIONS_TO_INFER_SER)) { return PropertyName.USE_DEFAULT; } return null; } @Override // since 2.9 public Boolean hasAsValue(Annotated a) { JsonValue ann = _findAnnotation(a, JsonValue.class); if (ann == null) { return null; } return ann.value(); } @Override // since 2.9 public Boolean hasAnyGetter(Annotated a) { JsonAnyGetter ann = _findAnnotation(a, JsonAnyGetter.class); if (ann == null) { return null; } return ann.enabled(); } @Override @Deprecated // since 2.9 public boolean hasAnyGetterAnnotation(AnnotatedMethod am) { // No dedicated disabling; regular @JsonIgnore used if needs to be ignored (handled separately) return _hasAnnotation(am, JsonAnyGetter.class); } @Override

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>gment call, but I don't think JDK ever implies // use of delegate; assumes as-properties implicitly return JsonCreator.Mode.PROPERTIES; } } } } return null; } /* /********************************************************** /* Helper methods /********************************************************** */ protected boolean _isIgnorable(Annotated a) { JsonIgnore ann = _findAnnotation(a, JsonIgnore.class); if (ann != null) { return ann.value(); } if (_java7Helper != null) { Boolean b = _java7Helper.findTransient(a); if (b != null) { return b.booleanValue(); } } return false; } protected Class<?> _classIfExplicit(Class<?> cls) { if (cls == null || ClassUtil.isBogusClass(cls)) { return null; } return cls; } protected Class<?> _classIfExplicit(Class<?> cls, Class<?> implicit) { cls = _classIfExplicit(cls); return (cls == null || cls == implicit) ? null : cls; } protected PropertyName _propertyName(String localName, String namespace) { if (localName.isEmpty()) { return PropertyName.USE_DEFAULT; } if (namespace == null || namespace.isEmpty()) { return PropertyName.construct(localName); } return PropertyName.construct(localName, namespace); } protected PropertyName _findConstructorName(Annotated a) { if (a instanceof AnnotatedParameter) { AnnotatedParameter p = (AnnotatedParameter) a; AnnotatedWithParams ctor = p.getOwner(); if (ctor != null) { if (_java7Helper != null) { PropertyName name = _java7Helper.findConstructorName(p); if (name != null) { return name; } } } } return null; } /** * Helper method called to construct and initialize instance of {@link TypeResolverBuilder} * if given annotated element indicates one is needed. */ @SuppressWarnings("deprecation") protected TypeResolverBuilder<?> _findTypeResolver(MapperConfig<?> config, Annotated ann, JavaType baseType) { // First: maybe we have explicit type resolver? TypeResolverBuilder<?>

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> ctxt.handleInstantiationProblem(_valueClass, value, ClassUtil.getRootCause(e)); } case STD_JAVA_TYPE: return ctxt.getTypeFactory().constructFromCanonical(value); case STD_CURRENCY: // will throw IAE if unknown: return Currency.getInstance(value); case STD_PATTERN: // will throw IAE (or its subclass) if malformed return Pattern.compile(value); case STD_LOCALE: { int ix = _firstHyphenOrUnderscore(value); if (ix < 0) { // single argument return new Locale(value); } String first = value.substring(0, ix); value = value.substring(ix+1); ix = _firstHyphenOrUnderscore(value); if (ix < 0) { // two pieces return new Locale(first, value); } String second = value.substring(0, ix); return new Locale(first, second, value.substring(ix+1)); } case STD_CHARSET: return Charset.forName(value); case STD_TIME_ZONE: return TimeZone.getTimeZone(value); case STD_INET_ADDRESS: return InetAddress.getByName(value); case STD_INET_SOCKET_ADDRESS: if (value.startsWith("[")) { // bracketed IPv6 (with port number) int i = value.lastIndexOf(']'); if (i == -1) { throw new InvalidFormatException(ctxt.getParser(), "Bracketed IPv6 address must contain closing bracket", value, InetSocketAddress.class); } int j = value.indexOf(':', i); int port = j > -1 ? Integer.parseInt(value.substring(j + 1)) : 0; return new InetSocketAddress(value.substring(0, i + 1), port); } int ix = value.indexOf(':'); if (ix >= 0 && value.indexOf(':', ix + 1) < 0) { // host:port int port = Integer.parseInt(value.substring(ix+1)); return new InetSocketAddress(value.substring(0, ix), port); } // host or unbracketed IPv6, without port number return new Inet

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>>)converter; _delegateType = null; _delegateDeserializer = null; } @SuppressWarnings("unchecked") public StdDelegatingDeserializer(Converter<Object,T> converter, JavaType delegateType, JsonDeserializer<?> delegateDeserializer) { super(delegateType); _converter = converter; _delegateType = delegateType; _delegateDeserializer = (JsonDeserializer<Object>) delegateDeserializer; } /** * @since 2.5 */ protected StdDelegatingDeserializer(StdDelegatingDeserializer<T> src) { super(src); _converter = src._converter; _delegateType = src._delegateType; _delegateDeserializer = src._delegateDeserializer; } /** * Method used for creating resolved contextual instances. Must be * overridden when sub-classing. */ protected StdDelegatingDeserializer<T> withDelegate(Converter<Object,T> converter, JavaType delegateType, JsonDeserializer<?> delegateDeserializer) { ClassUtil.verifyMustOverride(StdDelegatingDeserializer.class, this, "withDelegate"); return new StdDelegatingDeserializer<T>(converter, delegateType, delegateDeserializer); } /* /********************************************************** /* Contextualization /********************************************************** */ // Note: unlikely to get called since most likely instances explicitly constructed; // if so, caller must ensure delegating deserializer is properly resolve()d. @Override public void resolve(DeserializationContext ctxt) throws JsonMappingException { if (_delegateDeserializer != null && _delegateDeserializer instanceof ResolvableDeserializer) { ((ResolvableDeserializer) _delegateDeserializer).resolve(ctxt); } } @Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { // First: if already got serializer to delegate to, contextualize it: if (_delegateDeserializer != null) { JsonDeserializer<?> deser = ctxt.handleSecondaryContextualization(_delegateDeserializer, property, _delegateType); if (deser != _delegateDeserializer) { return withDelegate(_converter, _delegateType, deser); } return this; } // Otherwise: figure out what is the fully generic delegate type, then find deserializer JavaType delegateType = _converter.getInputType(ctxt.getTypeFactory()); return withDelegate(_converter, delegateType,

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>defaultBean = def; } return (def == NO_DEFAULT_MARKER) ? null : _defaultBean; } /** * Accessor used to find out "default value" for given property, to use for * comparing values to serialize, to determine whether to exclude value from serialization with * inclusion type of {@link com.fasterxml.jackson.annotation.JsonInclude.Include#NON_DEFAULT}. * This method is called when we specifically want to know default value within context * of a POJO, when annotation is within containing class, and not for property or * defined as global baseline. *<p> * Note that returning of pseudo-type * {@link com.fasterxml.jackson.annotation.JsonInclude.Include#NON_EMPTY} requires special handling. * * @since 2.7 * @deprecated Since 2.9 since this will not allow determining difference between "no default instance" * case and default being `null`. */ @Deprecated // since 2.9 protected Object getPropertyDefaultValue(String name, AnnotatedMember member, JavaType type) { Object defaultBean = getDefaultBean(); if (defaultBean == null) { return getDefaultValue(type); } try { return member.getValue(defaultBean); } catch (Exception e) { return _throwWrapped(e, name, defaultBean); } } /** * @deprecated Since 2.9 */ @Deprecated // since 2.9 protected Object getDefaultValue(JavaType type) { return BeanUtil.getDefaultValue(type); } /* /********************************************************** /* Helper methods for exception handling /********************************************************** */ protected Object _throwWrapped(Exception e, String propName, Object defaultBean) { Throwable t = e; while (t.getCause() != null) { t = t.getCause(); } ClassUtil.throwIfError(t); ClassUtil.throwIfRTE(t); throw new IllegalArgumentException("Failed to get property '"+propName+"' of default "+defaultBean.getClass().getName()+" instance"); } }

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>Index = base._enumsByIndex; _enumDefaultValue = base._enumDefaultValue; _caseInsensitive = caseInsensitive; } /** * @deprecated Since 2.9 */ @Deprecated public EnumDeserializer(EnumResolver byNameResolver) { this(byNameResolver, null); } /** * @deprecated Since 2.8 */ @Deprecated public static JsonDeserializer<?> deserializerForCreator(DeserializationConfig config, Class<?> enumClass, AnnotatedMethod factory) { return deserializerForCreator(config, enumClass, factory, null, null); } /** * Factory method used when Enum instances are to be deserialized * using a creator (static factory method) * * @return Deserializer based on given factory method * * @since 2.8 */ public static JsonDeserializer<?> deserializerForCreator(DeserializationConfig config, Class<?> enumClass, AnnotatedMethod factory, ValueInstantiator valueInstantiator, SettableBeanProperty[] creatorProps) { if (config.canOverrideAccessModifiers()) { ClassUtil.checkAndFixAccess(factory.getMember(), config.isEnabled(MapperFeature.OVERRIDE_PUBLIC_ACCESS_MODIFIERS)); } return new FactoryBasedEnumDeserializer(enumClass, factory, factory.getParameterType(0), valueInstantiator, creatorProps); } /** * Factory method used when Enum instances are to be deserialized * using a zero-/no-args factory method * * @return Deserializer based on given no-args factory method * * @since 2.8 */ public static JsonDeserializer<?> deserializerForNoArgsCreator(DeserializationConfig config, Class<?> enumClass, AnnotatedMethod factory) { if (config.canOverrideAccessModifiers()) { ClassUtil.checkAndFixAccess(factory.getMember(), config.isEnabled(MapperFeature.OVERRIDE_PUBLIC_ACCESS_MODIFIERS)); } return new FactoryBasedEnumDeserializer(enumClass, factory); } /** * @since 2.9 */ public EnumDeserializer withResolved(Boolean caseInsensitive) { if (_caseInsensitive == caseInsensitive) { return this; } return new EnumDeserializer(this, caseInsensitive); } @Override // since 2.

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> return types; if (!",".equals(token)) { throw _problem(tokens, "Unexpected token '"+token+"', expected ',' or '>')"); } } throw _problem(tokens, "Unexpected end-of-string"); } protected Class<?> findClass(String className, MyTokenizer tokens) { try { return _factory.findClass(className); } catch (Exception e) { ClassUtil.throwIfRTE(e); throw _problem(tokens, "Can not locate class '"+className+"', problem: "+e.getMessage()); } } protected IllegalArgumentException _problem(MyTokenizer tokens, String msg) { return new IllegalArgumentException("Failed to parse type '"+tokens.getAllInput() +"' (remaining: '"+tokens.getRemainingInput()+"'): "+msg); } final static class MyTokenizer extends StringTokenizer { protected final String _input; protected int _index; protected String _pushbackToken; public MyTokenizer(String str) { super(str, "<,>", true); _input = str; } @Override public boolean hasMoreTokens() { return (_pushbackToken != null) || super.hasMoreTokens(); } @Override public String nextToken() { String token; if (_pushbackToken != null) { token = _pushbackToken; _pushbackToken = null; } else { token = super.nextToken(); } _index += token.length(); return token; } public void pushBack(String token) { _pushbackToken = token; _index -= token.length(); } public String getAllInput() { return _input; } public String getUsedInput() { return _input.substring(0, _index); } public String getRemainingInput() { return _input.substring(_index); } } }

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> fields first, then ours. fields = _findFields(new TypeResolutionContext.Basic(_typeFactory, parent.getBindings()), parent, fields); for (Field f : ClassUtil.getDeclaredFields(cls)) { // static fields not included (transients are at this point, filtered out later) if (!_isIncludableField(f)) { continue; } // Ok now: we can (and need) not filter out ignorable fields at this point; partly // because mix-ins haven't been added, and partly because logic can be done // when determining get/settability of the field. if (fields == null) { fields = new LinkedHashMap<>(); } FieldBuilder b = new FieldBuilder(tc, f); if (_intr != null) { b.annotations = collectAnnotations(b.annotations, f.getDeclaredAnnotations()); } fields.put(f.getName(), b); } // And then... any mix-in overrides? if (_mixInResolver != null) { Class<?> mixin = _mixInResolver.findMixInClassFor(cls); if (mixin != null) { _addFieldMixIns(mixin, cls, fields); } } return fields; } /** * Method called to add field mix-ins from given mix-in class (and its fields) * into already collected actual fields (from introspected classes and their * super-classes) */ private void _addFieldMixIns(Class<?> mixInCls, Class<?> targetClass, Map<String,FieldBuilder> fields) { List<Class<?>> parents = ClassUtil.findSuperClasses(mixInCls, targetClass, true); for (Class<?> mixin : parents) { for (Field mixinField : ClassUtil.getDeclaredFields(mixin)) { // there are some dummy things (static, synthetic); better ignore if (!_isIncludableField(mixinField)) { continue; } String name = mixinField.getName(); // anything to mask? (if not, quietly ignore) FieldBuilder b = fields.get(name); if (b != null) { b.annotations = collectAnnotations(b.annotations, mixinField.getDeclaredAnnotations()); } } } } private boolean _isInclud

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>Annotated ann, Object deserDef) throws JsonMappingException { if (deserDef == null) { return null; } JsonDeserializer<?> deser; if (deserDef instanceof JsonDeserializer) { deser = (JsonDeserializer<?>) deserDef; } else { /* Alas, there's no way to force return type of "either class * X or Y" -- need to throw an exception after the fact */ if (!(deserDef instanceof Class)) { throw new IllegalStateException("AnnotationIntrospector returned deserializer definition of type "+deserDef.getClass().getName()+"; expected type JsonDeserializer or Class<JsonDeserializer> instead"); } Class<?> deserClass = (Class<?>)deserDef; // there are some known "no class" markers to consider too: if (deserClass == JsonDeserializer.None.class || ClassUtil.isBogusClass(deserClass)) { return null; } if (!JsonDeserializer.class.isAssignableFrom(deserClass)) { throw new IllegalStateException("AnnotationIntrospector returned Class "+deserClass.getName()+"; expected Class<JsonDeserializer>"); } HandlerInstantiator hi = _config.getHandlerInstantiator(); deser = (hi == null) ? null : hi.deserializerInstance(_config, ann, deserClass); if (deser == null) { deser = (JsonDeserializer<?>) ClassUtil.createInstance(deserClass, _config.canOverrideAccessModifiers()); } } // First: need to resolve if (deser instanceof ResolvableDeserializer) { ((ResolvableDeserializer) deser).resolve(this); } return (JsonDeserializer<Object>) deser; } @Override public final KeyDeserializer keyDeserializerInstance(Annotated ann, Object deserDef) throws JsonMappingException { if (deserDef == null) { return null; } KeyDeserializer deser; if (deserDef instanceof KeyDeserializer) { deser = (KeyDeserializer) deserDef; } else { if (!(deserDef instanceof Class)) { throw new IllegalStateException("AnnotationIntrospector returned key deserializer definition of type " +deserDef.getClass().getName() +"; expected type KeyDeserializer or Class<KeyDeserializer> instead"); } Class<?> deserClass = (Class<?>)de

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>serDef; // there are some known "no class" markers to consider too: if (deserClass == KeyDeserializer.None.class || ClassUtil.isBogusClass(deserClass)) { return null; } if (!KeyDeserializer.class.isAssignableFrom(deserClass)) { throw new IllegalStateException("AnnotationIntrospector returned Class "+deserClass.getName() +"; expected Class<KeyDeserializer>"); } HandlerInstantiator hi = _config.getHandlerInstantiator(); deser = (hi == null) ? null : hi.keyDeserializerInstance(_config, ann, deserClass); if (deser == null) { deser = (KeyDeserializer) ClassUtil.createInstance(deserClass, _config.canOverrideAccessModifiers()); } } // First: need to resolve if (deser instanceof ResolvableDeserializer) { ((ResolvableDeserializer) deser).resolve(this); } return deser; } /* /********************************************************** /* Extended API /********************************************************** */ /** * Fluent factory method used for constructing a blueprint instance * with different factory */ public abstract DefaultDeserializationContext with(DeserializerFactory factory); /** * Method called to create actual usable per-deserialization * context instance. */ public abstract DefaultDeserializationContext createInstance( DeserializationConfig config, JsonParser jp, InjectableValues values); /* /********************************************************** /* And then the concrete implementation class /********************************************************** */ /** * Actual full concrete implementation */ public final static class Impl extends DefaultDeserializationContext { private static final long serialVersionUID = 1L; /** * Default constructor for a blueprint object, which will use the standard * {@link DeserializerCache}, given factory. */ public Impl(DeserializerFactory df) { super(df, null); } protected Impl(Impl src, DeserializationConfig config, JsonParser jp, InjectableValues values) { super(src, config, jp, values); } protected Impl(Impl src) { super(src); } protected Impl(Impl src, DeserializerFactory factory) { super(src, factory); } @Override public DefaultDeserializationContext copy() { ClassUtil.verifyMustOverride(Impl.class, this, "copy"); return new

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> } return null; } @Override public AnnotatedMethod getSetter() { if ((_member instanceof AnnotatedMethod) && ((AnnotatedMethod) _member).getParameterCount() == 1) { return (AnnotatedMethod) _member; } return null; } @Override public AnnotatedField getField() { return (_member instanceof AnnotatedField) ? (AnnotatedField) _member : null; } @Override public AnnotatedParameter getConstructorParameter() { return (_member instanceof AnnotatedParameter) ? (AnnotatedParameter) _member : null; } @Override public Iterator<AnnotatedParameter> getConstructorParameters() { AnnotatedParameter param = getConstructorParameter(); if (param == null) { return ClassUtil.emptyIterator(); } return Collections.singleton(param).iterator(); } @Override public AnnotatedMember getPrimaryMember() { return _member; } }

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS><Map.Entry>? Class<?> type = anyField.getRawType(); if (!Map.class.isAssignableFrom(type)) { throw new IllegalArgumentException(String.format( "Invalid 'any-setter' annotation on field '%s': type is not instance of java.util.Map", anyField.getName())); } return anyField; } } return null; } @Override public Map<Object, AnnotatedMember> findInjectables() { if (_propCollector != null) { return _propCollector.getInjectables(); } return Collections.emptyMap(); } @Override public List<AnnotatedConstructor> getConstructors() { return _classInfo.getConstructors(); } @Override public Object instantiateBean(boolean fixAccess) { AnnotatedConstructor ac = _classInfo.getDefaultConstructor(); if (ac == null) { return null; } if (fixAccess) { ac.fixAccess(_config.isEnabled(MapperFeature.OVERRIDE_PUBLIC_ACCESS_MODIFIERS)); } try { return ac.getAnnotated().newInstance(); } catch (Exception e) { Throwable t = e; while (t.getCause() != null) { t = t.getCause(); } ClassUtil.throwIfError(t); ClassUtil.throwIfRTE(t); throw new IllegalArgumentException("Failed to instantiate bean of type "+_classInfo.getAnnotated().getName()+": ("+t.getClass().getName()+") "+t.getMessage(), t); } } /* /********************************************************** /* Simple accessors, extended /********************************************************** */ @Override public AnnotatedMethod findMethod(String name, Class<?>[] paramTypes) { return _classInfo.findMethod(name, paramTypes); } /* /********************************************************** /* General per-class annotation introspection /********************************************************** */ @Override public JsonFormat.Value findExpectedFormat(JsonFormat.Value defValue) { // 15-Apr-2016, tatu: Let's check both per-type defaults and annotations; per-type // defaults having higher precedence, so start with that if (_annotationIntrospector != null) { JsonFormat.Value v = _annotationIntrospector.findFormat

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> } return _createConverter(_annotationIntrospector.findDeserializationConverter(_classInfo)); } @Override public String findClassDescription() { return (_annotationIntrospector == null) ? null : _annotationIntrospector.findClassDescription(_classInfo); } /* /********************************************************** /* Helper methods for field introspection /********************************************************** */ /** * @param ignoredProperties (optional) names of properties to ignore; * any fields that would be recognized as one of these properties * is ignored. * @param forSerialization If true, will collect serializable property * fields; if false, deserializable * * @return Ordered Map with logical property name as key, and * matching field as value. * * @deprecated Since 2.7.2, does not seem to be used? */ @Deprecated public LinkedHashMap<String,AnnotatedField> _findPropertyFields( Collection<String> ignoredProperties, boolean forSerialization) { LinkedHashMap<String,AnnotatedField> results = new LinkedHashMap<String,AnnotatedField>(); for (BeanPropertyDefinition property : _properties()) { AnnotatedField f = property.getField(); if (f != null) { String name = property.getName(); if (ignoredProperties != null) { if (ignoredProperties.contains(name)) { continue; } } results.put(name, f); } } return results; } /* /********************************************************** /* Helper methods, other /********************************************************** */ @SuppressWarnings("unchecked") protected Converter<Object,Object> _createConverter(Object converterDef) { if (converterDef == null) { return null; } if (converterDef instanceof Converter<?,?>) { return (Converter<Object,Object>) converterDef; } if (!(converterDef instanceof Class)) { throw new IllegalStateException("AnnotationIntrospector returned Converter definition of type " +converterDef.getClass().getName()+"; expected type Converter or Class<Converter> instead"); } Class<?> converterClass = (Class<?>)converterDef; // there are some known "no class" markers to consider too: if (converterClass == Converter.None.class || ClassUtil.isBogusClass(converterClass)) { return null;

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> } if (!Converter.class.isAssignableFrom(converterClass)) { throw new IllegalStateException("AnnotationIntrospector returned Class " +converterClass.getName()+"; expected Class<Converter>"); } HandlerInstantiator hi = _config.getHandlerInstantiator(); Converter<?,?> conv = (hi == null) ? null : hi.converterInstance(_config, _classInfo, converterClass); if (conv == null) { conv = (Converter<?,?>) ClassUtil.createInstance(converterClass, _config.canOverrideAccessModifiers()); } return (Converter<Object,Object>) conv; } }

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> property '%s'", getName())); // return _valueDeserializer.deserializeWithType(p, ctxt, _valueTypeDeserializer); } return _valueDeserializer.deserialize(p, ctxt, toUpdate); } /* /********************************************************** /* Helper methods /********************************************************** */ /** * Method that takes in exception of any type, and casts or wraps it * to an IOException or its subclass. */ protected void _throwAsIOE(JsonParser p, Exception e, Object value) throws IOException { if (e instanceof IllegalArgumentException) { String actType = ClassUtil.classNameOf(value); StringBuilder msg = new StringBuilder("Problem deserializing property '") .append(getName()) .append("' (expected type: ") .append(getType()) .append("; actual type: ") .append(actType).append(")"); String origMsg = e.getMessage(); if (origMsg != null) { msg.append(", problem: ") .append(origMsg); } else { msg.append(" (no error message provided)"); } throw JsonMappingException.from(p, msg.toString(), e); } _throwAsIOE(p, e); } /** * @since 2.7 */ protected IOException _throwAsIOE(JsonParser p, Exception e) throws IOException { ClassUtil.throwIfIOE(e); ClassUtil.throwIfRTE(e); // let's wrap the innermost problem Throwable th = ClassUtil.getRootCause(e); throw JsonMappingException.from(p, th.getMessage(), th); } @Deprecated // since 2.7 protected IOException _throwAsIOE(Exception e) throws IOException { return _throwAsIOE((JsonParser) null, e); } // 10-Oct-2015, tatu: _Should_ be deprecated, too, but its remaining // callers can not actually provide a JsonParser protected void _throwAsIOE(Exception e, Object value) throws IOException { _throwAsIOE((JsonParser) null, e, value); } @Override public String toString() { return "[property '"+getName()+"']"; } /* /********************************************************** /* Helper classes /**********************************************************

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> value = valueDes.deserializeWithType(p, ctxt, typeDeser); } } catch (Exception e) { return wrapAndThrow(e, result, keyName); } result.put(key, value); } return result; } @Override public Object deserializeWithType(JsonParser p, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws IOException { // In future could check current token... for now this should be enough: return typeDeserializer.deserializeTypedFromObject(p, ctxt); } protected EnumMap<?,?> constructMap(DeserializationContext ctxt) throws JsonMappingException { if (_valueInstantiator == null) { return new EnumMap(_enumClass); } try { if (!_valueInstantiator.canCreateUsingDefault()) { return (EnumMap<?,?>) ctxt.handleMissingInstantiator(handledType(), getValueInstantiator(), null, "no default constructor found"); } return (EnumMap<?,?>) _valueInstantiator.createUsingDefault(ctxt); } catch (IOException e) { return ClassUtil.throwAsMappingException(ctxt, e); } } public EnumMap<?,?> _deserializeUsingProperties(JsonParser p, DeserializationContext ctxt) throws IOException { final PropertyBasedCreator creator = _propertyBasedCreator; // null -> no ObjectIdReader for EnumMaps PropertyValueBuffer buffer = creator.startBuilding(p, ctxt, null); String keyName; if (p.isExpectedStartObjectToken()) { keyName = p.nextFieldName(); } else if (p.hasToken(JsonToken.FIELD_NAME)) { keyName = p.getCurrentName(); } else { keyName = null; } for (; keyName != null; keyName = p.nextFieldName()) { JsonToken t = p.nextToken(); // to get to value // creator property? SettableBeanProperty prop = creator.findCreatorProperty(keyName); if (prop != null) { // Last property to set? if (buffer.assignParameter(prop, prop.deserialize(p, ctxt))) { EnumMap<?,?> result; try { result = (EnumMap<?,?>)creator.build(ctxt, buffer); } catch (Exception e) { return wrapAndThrow(e

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>package com.fasterxml.jackson.databind.util; import java.io.Closeable; import java.io.IOException; import java.lang.annotation.Annotation; import java.lang.reflect.*; import java.util.*; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; public final class ClassUtil { private final static Class<?> CLS_OBJECT = Object.class; private final static Annotation[] NO_ANNOTATIONS = new Annotation[0]; private final static Ctor[] NO_CTORS = new Ctor[0]; private final static Iterator<?> EMPTY_ITERATOR = Collections.emptyIterator(); /* /********************************************************** /* Simple factory methods /********************************************************** */ /** * @since 2.7 */ @SuppressWarnings("unchecked") public static <T> Iterator<T> emptyIterator() { return (Iterator<T>) EMPTY_ITERATOR; } /* /********************************************************** /* Methods that deal with inheritance /********************************************************** */ /** * Method that will find all sub-classes and implemented interfaces * of a given class or interface. Classes are listed in order of * precedence, starting with the immediate super-class, followed by * interfaces class directly declares to implemented, and then recursively * followed by parent of super-class and so forth. * Note that <code>Object.class</code> is not included in the list * regardless of whether <code>endBefore</code> argument is defined or not. * * @param endBefore Super-type to NOT include in results, if any; when * encountered, will be ignored (and no super types are checked). * * @since 2.7 */ public static List<JavaType> findSuperTypes(JavaType type, Class<?> endBefore, boolean addClassItself) { if ((type == null) || type.hasRawClass(endBefore) || type.hasRawClass(Object.class)) { return Collections.emptyList(); } List<JavaType> result = new ArrayList<

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> { return; } if (addClassItself) { if (result.contains(type)) { // already added, no need to check supers return; } result.add(type); } for (JavaType intCls : type.getInterfaces()) { _addSuperTypes(intCls, endBefore, result, true); } _addSuperTypes(type.getSuperClass(), endBefore, result, true); } private static void _addRawSuperTypes(Class<?> cls, Class<?> endBefore, Collection<Class<?>> result, boolean addClassItself) { if (cls == endBefore || cls == null || cls == Object.class) { return; } if (addClassItself) { if (result.contains(cls)) { // already added, no need to check supers return; } result.add(cls); } for (Class<?> intCls : _interfaces(cls)) { _addRawSuperTypes(intCls, endBefore, result, true); } _addRawSuperTypes(cls.getSuperclass(), endBefore, result, true); } /* /********************************************************** /* Class type detection methods /********************************************************** */ /** * @return Null if class might be a bean; type String (that identifies * why it's not a bean) if not */ public static String canBeABeanType(Class<?> type) { // First: language constructs that ain't beans: if (type.isAnnotation()) { return "annotation"; } if (type.isArray()) { return "array"; } if (type.isEnum()) { return "enum"; } if (type.isPrimitive()) { return "primitive"; } // Anything else? Seems valid, then return null; } public static String isLocalType(Class<?> type, boolean allowNonStatic) { /* As per [JACKSON-187], GAE seems to throw SecurityExceptions * here and there... and GAE itself has a bug, too * (see []). Bah. So we need to catch some wayward exceptions on GAE */ try { // one more: method locals, anonymous, are not good: if (hasEnclosing

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> public static boolean isConcrete(Member member) { int mod = member.getModifiers(); return (mod & (Modifier.INTERFACE | Modifier.ABSTRACT)) == 0; } public static boolean isCollectionMapOrArray(Class<?> type) { if (type.isArray()) return true; if (Collection.class.isAssignableFrom(type)) return true; if (Map.class.isAssignableFrom(type)) return true; return false; } public static boolean isBogusClass(Class<?> cls) { return (cls == Void.class || cls == Void.TYPE || cls == com.fasterxml.jackson.databind.annotation.NoClass.class); } public static boolean isNonStaticInnerClass(Class<?> cls) { return !Modifier.isStatic(cls.getModifiers()) && (getEnclosingClass(cls) != null); } /** * @since 2.7 */ public static boolean isObjectOrPrimitive(Class<?> cls) { return (cls == CLS_OBJECT) || cls.isPrimitive(); } /** * @since 2.9 */ public static boolean hasClass(Object inst, Class<?> raw) { // 10-Nov-2016, tatu: Could use `Class.isInstance()` if we didn't care // about being exactly that type return (inst != null) && (inst.getClass() == raw); } /** * @since 2.9 */ public static void verifyMustOverride(Class<?> expType, Object instance, String method) { if (instance.getClass() != expType) { throw new IllegalStateException(String.format( "Sub-class %s (of class %s) must override method '%s'", instance.getClass().getName(), expType.getName(), method)); } } /* /********************************************************** /* Method type detection methods /********************************************************** */ /** * @deprecated Since 2.6 not used; may be removed before 3.x */ @Deprecated // since 2.6 public static boolean hasGetterSignature(Method m) { // First: static methods can't be getters if (Modifier.isStatic(m.getModifiers())) { return false; } //

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> { Constructor<T> ctor = findConstructor(cls, canFixAccess); if (ctor == null) { throw new IllegalArgumentException("Class "+cls.getName()+" has no default (no arg) constructor"); } try { return ctor.newInstance(); } catch (Exception e) { ClassUtil.unwrapAndThrowAsIAE(e, "Failed to instantiate class "+cls.getName()+", problem: "+e.getMessage()); return null; } } public static <T> Constructor<T> findConstructor(Class<T> cls, boolean forceAccess) throws IllegalArgumentException { try { Constructor<T> ctor = cls.getDeclaredConstructor(); if (forceAccess) { checkAndFixAccess(ctor, forceAccess); } else { // Has to be public... if (!Modifier.isPublic(ctor.getModifiers())) { throw new IllegalArgumentException("Default constructor for "+cls.getName()+" is not accessible (non-public?): not allowed to try modify access via Reflection: can not instantiate type"); } } return ctor; } catch (NoSuchMethodException e) { ; } catch (Exception e) { ClassUtil.unwrapAndThrowAsIAE(e, "Failed to find default constructor of class "+cls.getName()+", problem: "+e.getMessage()); } return null; } /* /********************************************************** /* Class name, description access /********************************************************** */ /** * @since 2.9 */ public static Class<?> classOf(Object inst) { if (inst == null) { return null; } return inst.getClass(); } /** * @since 2.9 */ public static <T> T nonNull(T valueOrNull, T defaultValue) { return (valueOrNull == null) ? defaultValue : valueOrNull; } /** * @since 2.9 */ public static String nullOrToString(Object value) { if (value == null) { return null; } return value.toString(); } /** * @since 2.9 */ public static String nonNullString(String str) { if (str == null) { return ""; } return str; } /** * Returns either quoted value (with double-quotes) --

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> if argument non-null * String -- or String NULL (no quotes) (if null). * * @since 2.9 */ public static String quotedOr(Object str, String forNull) { if (str == null) { return forNull; } return String.format("\"%s\"", str); } /* /********************************************************** /* Type name handling methods /********************************************************** */ /** * Helper method used to construct appropriate description * when passed either type (Class) or an instance; in latter * case, class of instance is to be used. */ public static String getClassDescription(Object classOrInstance) { if (classOrInstance == null) { return "unknown"; } Class<?> cls = (classOrInstance instanceof Class<?>) ? (Class<?>) classOrInstance : classOrInstance.getClass(); return cls.getName(); } /** * @since 2.9 */ public static String classNameOf(Object inst) { if (inst == null) { return "[null]"; } return inst.getClass().getName(); } /** * Returns either `cls.getName()` (if `cls` not null), * or "[null]" if `cls` is null. * * @since 2.9 */ public static String nameOf(Class<?> cls) { if (cls == null) { return "[null]"; } if (cls.isArray()) { return nameOf(cls.getComponentType())+"[]"; } if (cls.isPrimitive()) { cls.getSimpleName(); } return cls.getName(); } /** * Returns either (double-)quoted `named.getName()` (if `named` not null), * or "[null]" if `named` is null. * * @since 2.9 */ public static String nameOf(Named named) { if (named == null) { return "[null]"; } return String.format("'%s'", named.getName()); } /* /********************************************************** /* Primitive type support /********************************************************** */ /** * Helper method used to get default value for wrappers used for primitive types * (0 for Integer etc) */ public static Object defaultValue(Class<?> cls

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>) { if (cls == Integer.TYPE) { return Integer.valueOf(0); } if (cls == Long.TYPE) { return Long.valueOf(0L); } if (cls == Boolean.TYPE) { return Boolean.FALSE; } if (cls == Double.TYPE) { return Double.valueOf(0.0); } if (cls == Float.TYPE) { return Float.valueOf(0.0f); } if (cls == Byte.TYPE) { return Byte.valueOf((byte) 0); } if (cls == Short.TYPE) { return Short.valueOf((short) 0); } if (cls == Character.TYPE) { return '\0'; } throw new IllegalArgumentException("Class "+cls.getName()+" is not a primitive type"); } /** * Helper method for finding wrapper type for given primitive type (why isn't * there one in JDK?) */ public static Class<?> wrapperType(Class<?> primitiveType) { if (primitiveType == Integer.TYPE) { return Integer.class; } if (primitiveType == Long.TYPE) { return Long.class; } if (primitiveType == Boolean.TYPE) { return Boolean.class; } if (primitiveType == Double.TYPE) { return Double.class; } if (primitiveType == Float.TYPE) { return Float.class; } if (primitiveType == Byte.TYPE) { return Byte.class; } if (primitiveType == Short.TYPE) { return Short.class; } if (primitiveType == Character.TYPE) { return Character.class; } throw new IllegalArgumentException("Class "+primitiveType.getName()+" is not a primitive type"); } /** * Method that can be used to find primitive type for given class if (but only if) * it is either wrapper type or primitive type; returns `null` if type is neither. * * @since 2.7 */ public static Class<?> primitiveType(Class<?> type) { if (type.isPrimitive()) { return type; } if (type == Integer.class) { return Integer.TYPE; } if (type ==

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS><p> * NOTE: passing `null` is legal, and will result in <code>true</code> * being returned. */ public static boolean isJacksonStdImpl(Object impl) { return (impl == null) || isJacksonStdImpl(impl.getClass()); } public static boolean isJacksonStdImpl(Class<?> implClass) { return (implClass.getAnnotation(JacksonStdImpl.class) != null); } /* /********************************************************** /* Access to various Class definition aspects; possibly /* cacheable; and attempts was made in 2.7.0 - 2.7.7; however /* unintented retention (~= memory leak) wrt [databind#1363] /* resulted in removal of caching /********************************************************** */ /** * @since 2.7 */ public static String getPackageName(Class<?> cls) { Package pkg = cls.getPackage(); return (pkg == null) ? null : pkg.getName(); } /** * @since 2.7 */ public static boolean hasEnclosingMethod(Class<?> cls) { return !isObjectOrPrimitive(cls) && (cls.getEnclosingMethod() != null); } /** * @since 2.7 */ public static Field[] getDeclaredFields(Class<?> cls) { return cls.getDeclaredFields(); } /** * @since 2.7 */ public static Method[] getDeclaredMethods(Class<?> cls) { return cls.getDeclaredMethods(); } /** * @since 2.7 */ public static Annotation[] findClassAnnotations(Class<?> cls) { if (isObjectOrPrimitive(cls)) { return NO_ANNOTATIONS; } return cls.getDeclaredAnnotations(); } /** * Helper method that gets methods declared in given class; usually a simple thing, * but sometimes (as per [databind#785]) more complicated, depending on classloader * setup. * * @since 2.9 */ public static Method[] getClassMethods(Class<?> cls) { try { return ClassUtil.getDeclaredMethods(cls); } catch (final NoClassDefFoundError ex) { // One of the methods had a class that was not found

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> */ @Deprecated public TypeResolutionContext getTypeContext() { return _typeContext; } @Override public final <A extends Annotation> A getAnnotation(Class<A> acls) { if (_annotations == null) { return null; } return _annotations.get(acls); } @Override public final boolean hasAnnotation(Class<?> acls) { if (_annotations == null) { return false; } return _annotations.has(acls); } @Override public boolean hasOneOf(Class<? extends Annotation>[] annoClasses) { if (_annotations == null) { return false; } return _annotations.hasOneOf(annoClasses); } /** *<p> * NOTE: promoted in 2.9 from `Annotated` up */ public AnnotationMap getAllAnnotations() { // alas, used by at least one module, hence public return _annotations; } /** * Method that can be called to modify access rights, by calling * {@link java.lang.reflect.AccessibleObject#setAccessible} on * the underlying annotated element. *<p> * Note that caller should verify that * {@link com.fasterxml.jackson.databind.MapperFeature#CAN_OVERRIDE_ACCESS_MODIFIERS} * is enabled before calling this method; as well as pass * <code>force</code> flag appropriately. * * @since 2.7 */ public final void fixAccess(boolean force) { Member m = getMember(); if (m != null) { // may be null for virtual members ClassUtil.checkAndFixAccess(m, force); } } /** * Optional method that can be used to assign value of * this member on given object, if this is a supported * operation for member type. *<p> * This is implemented for fields and single-argument * member methods; but not for constructor parameters or * other types of methods (like static methods) */ public abstract void setValue(Object pojo, Object value) throws UnsupportedOperationException, IllegalArgumentException; /** * Optional method that can be used to access the value of * this member on given object, if this is a supported * operation for member type. *<p>

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> 2.2 */ public SerializationConfig getConfig() { return _config; } /** * @since 2.2 */ public JsonFactory getFactory() { return _generatorFactory; } public TypeFactory getTypeFactory() { return _config.getTypeFactory(); } /** * Diagnostics method that can be called to check whether this writer * has pre-fetched serializer to use: pre-fetching improves performance * when writer instances are reused as it avoids a per-call serializer * lookup. * * @since 2.2 */ public boolean hasPrefetchedSerializer() { return _prefetch.hasSerializer(); } /** * @since 2.3 */ public ContextAttributes getAttributes() { return _config.getAttributes(); } /* /********************************************************** /* Serialization methods; ones from ObjectCodec first /********************************************************** */ /** * Method that can be used to serialize any Java value as * JSON output, using provided {@link JsonGenerator}. */ public void writeValue(JsonGenerator gen, Object value) throws IOException { _configureGenerator(gen); if (_config.isEnabled(SerializationFeature.CLOSE_CLOSEABLE) && (value instanceof Closeable)) { Closeable toClose = (Closeable) value; try { _prefetch.serialize(gen, value, _serializerProvider()); if (_config.isEnabled(SerializationFeature.FLUSH_AFTER_WRITE_VALUE)) { gen.flush(); } } catch (Exception e) { ClassUtil.closeOnFailAndThrowAsIAE(null, toClose, e); return; } toClose.close(); } else { _prefetch.serialize(gen, value, _serializerProvider()); if (_config.isEnabled(SerializationFeature.FLUSH_AFTER_WRITE_VALUE)) { gen.flush(); } } } /* /********************************************************** /* Serialization methods, others /********************************************************** */ /** * Method that can be used to serialize any Java value as * JSON output, written to File provided. */ public void writeValue(File resultFile, Object value) throws IOException, JsonGenerationException, JsonMappingException { _configAndWriteValue(_generatorFactory.createGenerator(resultFile, JsonEncoding.UTF

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> public void acceptJsonFormatVisitor(Class<?> rawType, JsonFormatVisitorWrapper visitor) throws JsonMappingException { acceptJsonFormatVisitor(_config.constructType(rawType), visitor); } public boolean canSerialize(Class<?> type) { return _serializerProvider().hasSerializerFor(type, null); } /** * Method for checking whether instances of given type can be serialized, * and optionally why (as per {@link Throwable} returned). * * @since 2.3 */ public boolean canSerialize(Class<?> type, AtomicReference<Throwable> cause) { return _serializerProvider().hasSerializerFor(type, cause); } /* /********************************************************** /* Overridable helper methods /********************************************************** */ /** * Overridable helper method used for constructing * {@link SerializerProvider} to use for serialization. */ protected DefaultSerializerProvider _serializerProvider() { return _serializerProvider.createInstance(_config, _serializerFactory); } /* /********************************************************** /* Internal methods /********************************************************** */ /** * @since 2.2 */ protected void _verifySchemaType(FormatSchema schema) { if (schema != null) { if (!_generatorFactory.canUseSchema(schema)) { throw new IllegalArgumentException("Can not use FormatSchema of type "+schema.getClass().getName() +" for format "+_generatorFactory.getFormatName()); } } } /** * Method called to configure the generator as necessary and then * call write functionality */ protected final void _configAndWriteValue(JsonGenerator gen, Object value) throws IOException { _configureGenerator(gen); if (_config.isEnabled(SerializationFeature.CLOSE_CLOSEABLE) && (value instanceof Closeable)) { _writeCloseable(gen, value); return; } try { _prefetch.serialize(gen, value, _serializerProvider()); } catch (Exception e) { ClassUtil.closeOnFailAndThrowAsIAE(gen, e); return; } gen.close(); } /** * Helper method used when value to serialize is {@link Closeable} and its <code>close()</code> * method is to be called right after serialization has been called */ private final void _writeCloseable(JsonGenerator

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> gen, Object value) throws IOException { Closeable toClose = (Closeable) value; try { _prefetch.serialize(gen, value, _serializerProvider()); Closeable tmpToClose = toClose; toClose = null; tmpToClose.close(); } catch (Exception e) { ClassUtil.closeOnFailAndThrowAsIAE(gen, toClose, e); return; } gen.close(); } /** * Helper method called to set or override settings of passed-in * {@link JsonGenerator} * * @since 2.5 */ protected final void _configureGenerator(JsonGenerator gen) { // order is slightly significant: both may change PrettyPrinter // settings. _config.initialize(gen); // since 2.5 _generatorSettings.initialize(gen); } /* /********************************************************** /* Helper classes for configuration /********************************************************** */ /** * Helper class used for containing settings specifically related * to (re)configuring {@link JsonGenerator} constructed for * writing output. * * @since 2.5 */ public final static class GeneratorSettings implements java.io.Serializable { private static final long serialVersionUID = 1L; public final static GeneratorSettings empty = new GeneratorSettings(null, null, null, null); /** * To allow for dynamic enabling/disabling of pretty printing, * pretty printer can be optionally configured for writer * as well */ public final PrettyPrinter prettyPrinter; /** * When using data format that uses a schema, schema is passed * to generator. */ public final FormatSchema schema; /** * Caller may want to specify character escaping details, either as * defaults, or on call-by-call basis. */ public final CharacterEscapes characterEscapes; /** * Caller may want to override so-called "root value separator", * String added (verbatim, with no quoting or escaping) between * values in root context. Default value is a single space character, * but this is often changed to linefeed. */ public final SerializableString rootValueSeparator; public GeneratorSettings(PrettyPrinter pp, FormatSchema sch, CharacterEscapes esc, SerializableString rootSep) { prettyPrinter

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>) { ctxt.reportBadDefinition(getValueType(), String.format( "Can not define Creator property \"%s\" as `@JsonUnwrapped`: combination not yet supported", prop.getName())); } return unwrapper; } } return null; } /** * Helper method that will handle gruesome details of dealing with properties * that have non-static inner class as value... */ protected SettableBeanProperty _resolveInnerClassValuedProperty(DeserializationContext ctxt, SettableBeanProperty prop) { /* Should we encounter a property that has non-static inner-class * as value, we need to add some more magic to find the "hidden" constructor... */ JsonDeserializer<Object> deser = prop.getValueDeserializer(); // ideally wouldn't rely on it being BeanDeserializerBase; but for now it'll have to do if (deser instanceof BeanDeserializerBase) { BeanDeserializerBase bd = (BeanDeserializerBase) deser; ValueInstantiator vi = bd.getValueInstantiator(); if (!vi.canCreateUsingDefault()) { // no default constructor Class<?> valueClass = prop.getType().getRawClass(); // NOTE: almost same as `isNonStaticInnerClass()` but need to know enclosing... Class<?> enclosing = ClassUtil.getOuterClass(valueClass); // and is inner class of the bean class... if ((enclosing != null) && (enclosing == _beanType.getRawClass())) { for (Constructor<?> ctor : valueClass.getConstructors()) { Class<?>[] paramTypes = ctor.getParameterTypes(); if (paramTypes.length == 1) { if (enclosing.equals(paramTypes[0])) { if (ctxt.canOverrideAccessModifiers()) { ClassUtil.checkAndFixAccess(ctor, ctxt.isEnabled(MapperFeature.OVERRIDE_PUBLIC_ACCESS_MODIFIERS)); } return new InnerClassProperty(prop, ctor); } } } } } } return prop; } // @since 2.9 protected SettableBeanProperty _resolveMergeAndNullSettings(DeserializationContext ctxt, SettableBeanProperty prop, PropertyMetadata propMetadata) throws JsonMappingException { PropertyMetadata.MergeInfo merge = propMetadata.getMergeInfo(); // First

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> mergeability if (merge != null) { JsonDeserializer<?> valueDeser = prop.getValueDeserializer(); Boolean mayMerge = valueDeser.supportsUpdate(ctxt.getConfig()); if (mayMerge == null) { // we don't really know if it's ok; so only use if explicitly specified if (merge.fromDefaults) { return prop; } } else if (!mayMerge.booleanValue()) { // prevented if (!merge.fromDefaults) { // If attempts was made via explicit annotation/per-type config override, // should be reported; may or may not result in exception ctxt.reportBadMerge(valueDeser); } return prop; } // Anyway; if we get this far, do enable merging AnnotatedMember accessor = merge.getter; accessor.fixAccess(ctxt.isEnabled(MapperFeature.OVERRIDE_PUBLIC_ACCESS_MODIFIERS)); if (!(prop instanceof SetterlessProperty)) { prop = MergingSettableBeanProperty.construct(prop, accessor); } } // And after this, see if we require non-standard null handling NullValueProvider nuller = findValueNullProvider(ctxt, prop, propMetadata); if (nuller != null) { prop = prop.withNullProvider(nuller); } return prop; } /* /********************************************************** /* Public accessors; null/empty value providers /********************************************************** */ @Override public AccessPattern getNullAccessPattern() { // POJO types do not have custom `null` values return AccessPattern.ALWAYS_NULL; } @Override public AccessPattern getEmptyAccessPattern() { // Empty values can not be shared return AccessPattern.DYNAMIC; } @Override // since 2.9 public Object getEmptyValue(DeserializationContext ctxt) throws JsonMappingException { // alas, need to promote exception, if any: try { return _valueInstantiator.createUsingDefault(ctxt); } catch (IOException e) { return ClassUtil.throwAsMappingException(ctxt, e); } } /* /********************************************************** /* Public accessors; other /********************************************************** */ @Override public boolean isCachable() { return true; } @Override // since 2.9 public Boolean supports

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>er.deserialize(p, ctxt)); } if (_propertyBasedCreator != null) { return _deserializeUsingPropertyBased(p, ctxt); } // 25-Jan-2017, tatu: We do not actually support use of Creators for non-static // inner classes -- with one and only one exception; that of default constructor! // -- so let's indicate it Class<?> raw = _beanType.getRawClass(); if (ClassUtil.isNonStaticInnerClass(raw)) { return ctxt.handleMissingInstantiator(raw, null, p, "can only instantiate non-static inner class by using default, no-argument constructor"); } return ctxt.handleMissingInstantiator(raw, getValueInstantiator(), p, "can not deserialize from Object value (no delegate- or property-based Creator)"); } protected abstract Object _deserializeUsingPropertyBased(final JsonParser p, final DeserializationContext ctxt) throws IOException; public Object deserializeFromNumber(JsonParser p, DeserializationContext ctxt) throws IOException { // First things first: id Object Id is used, most likely that's it if (_objectIdReader != null) { return deserializeFromObjectId(p, ctxt); } final JsonDeserializer<Object> delegateDeser = _delegateDeserializer(); NumberType nt = p.getNumberType(); if (nt == NumberType.INT) { if (delegateDeser != null) { if (!_valueInstantiator.canCreateFromInt()) { Object bean = _valueInstantiator.createUsingDelegate(ctxt, delegateDeser.deserialize(p, ctxt)); if (_injectables != null) { injectValues(ctxt, bean); } return bean; } } return _valueInstantiator.createFromInt(ctxt, p.getIntValue()); } if (nt == NumberType.LONG) { if (delegateDeser != null) { if (!_valueInstantiator.canCreateFromInt()) { Object bean = _valueInstantiator.createUsingDelegate(ctxt, delegateDeser.deserialize(p, ctxt)); if (_injectables != null) { injectValues(ctxt, bean); } return bean; } } return _valueInstantiator.createFromLong(ctxt, p.getLongValue()); }

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>(); } // Errors to be passed as is ClassUtil.throwIfError(t); boolean wrap = (ctxt == null) || ctxt.isEnabled(DeserializationFeature.WRAP_EXCEPTIONS); // Ditto for IOExceptions; except we may want to wrap JSON exceptions if (t instanceof IOException) { if (!wrap || !(t instanceof JsonProcessingException)) { throw (IOException) t; } } else if (!wrap) { // [JACKSON-407] -- allow disabling wrapping for unchecked exceptions ClassUtil.throwIfRTE(t); } return t; } protected Object wrapInstantiationProblem(Throwable t, DeserializationContext ctxt) throws IOException { while (t instanceof InvocationTargetException && t.getCause() != null) { t = t.getCause(); } // Errors and "plain" IOExceptions to be passed as is ClassUtil.throwIfError(t); if (t instanceof IOException) { // Since we have no more information to add, let's not actually wrap.. throw (IOException) t; } boolean wrap = (ctxt == null) || ctxt.isEnabled(DeserializationFeature.WRAP_EXCEPTIONS); if (!wrap) { // [JACKSON-407] -- allow disabling wrapping for unchecked exceptions ClassUtil.throwIfRTE(t); } return ctxt.handleInstantiationProblem(_beanType.getRawClass(), null, t); } }

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>With(rawType, PACKAGE_PREFIX_JAVAX_XML)) { factoryName = SERIALIZERS_FOR_JAVAX_XML; } else { return null; } Object ob = instantiate(factoryName); if (ob == null) { // could warn, if we had logging system (j.u.l?) return null; } return ((Serializers) ob).findSerializer(config, type, beanDesc); } public JsonDeserializer<?> findDeserializer(JavaType type, DeserializationConfig config, BeanDescription beanDesc) throws JsonMappingException { final Class<?> rawType = type.getRawClass(); if (_jdk7Helper != null) { JsonDeserializer<?> deser = _jdk7Helper.getDeserializerForJavaNioFilePath(rawType); if (deser != null) { return deser; } } if ((CLASS_DOM_NODE != null) && CLASS_DOM_NODE.isAssignableFrom(rawType)) { return (JsonDeserializer<?>) instantiate(DESERIALIZER_FOR_DOM_NODE); } if ((CLASS_DOM_DOCUMENT != null) && CLASS_DOM_DOCUMENT.isAssignableFrom(rawType)) { return (JsonDeserializer<?>) instantiate(DESERIALIZER_FOR_DOM_DOCUMENT); } String className = rawType.getName(); String factoryName; if (className.startsWith(PACKAGE_PREFIX_JAVAX_XML) || hasSuperClassStartingWith(rawType, PACKAGE_PREFIX_JAVAX_XML)) { factoryName = DESERIALIZERS_FOR_JAVAX_XML; } else { return null; } Object ob = instantiate(factoryName); if (ob == null) { // could warn, if we had logging system (j.u.l?) return null; } return ((Deserializers) ob).findBeanDeserializer(type, config, beanDesc); } /* /********************************************************** /* Internal helper methods /********************************************************** */ private Object instantiate(String className) { try { return ClassUtil.createInstance(Class.forName(className), false); } catch (LinkageError e) { } // too many different kinds to enumerate here: catch (Exception e) { } return null; } /** * Since

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> * and only throw after certain number, or at the end of serialization. * * @since 2.8 */ public void reportMappingProblem(String message, Object... args) throws JsonMappingException { throw mappingException(message, args); } /** * Helper method called to indicate problem in POJO (serialization) definitions or settings * regarding specific Java type, unrelated to actual JSON content to map. * Default behavior is to construct and throw a {@link JsonMappingException}. * * @since 2.9 */ public <T> T reportBadTypeDefinition(BeanDescription bean, String msg, Object... msgArgs) throws JsonMappingException { String beanDesc = "N/A"; if (bean != null) { beanDesc = ClassUtil.nameOf(bean.getBeanClass()); } msg = String.format("Invalid type definition for type %s: %s", beanDesc, _format(msg, msgArgs)); throw InvalidDefinitionException.from(getGenerator(), msg, bean, null); } /** * Helper method called to indicate problem in POJO (serialization) definitions or settings * regarding specific property (of a type), unrelated to actual JSON content to map. * Default behavior is to construct and throw a {@link JsonMappingException}. * * @since 2.9 */ public <T> T reportBadPropertyDefinition(BeanDescription bean, BeanPropertyDefinition prop, String message, Object... msgArgs) throws JsonMappingException { message = _format(message, msgArgs); String propName = "N/A"; if (prop != null) { propName = _quotedString(prop.getName()); } String beanDesc = "N/A"; if (bean != null) { beanDesc = ClassUtil.nameOf(bean.getBeanClass()); } message = String.format("Invalid definition for property %s (of type %s): %s", propName, beanDesc, message); throw InvalidDefinitionException.from(getGenerator(), message, bean, prop); } @Override public <T> T reportBadDefinition(JavaType type, String msg) throws JsonMappingException { throw InvalidDefinitionException.from(getGenerator(), msg, type); } /** * @since

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> _reportIncompatibleRootType(Object value, JavaType rootType) throws IOException { // One special case: allow primitive/wrapper type coercion if (rootType.isPrimitive()) { Class<?> wrapperType = ClassUtil.wrapperType(rootType.getRawClass()); // If it's just difference between wrapper, primitive, let it slide if (wrapperType.isAssignableFrom(value.getClass())) { return; } } reportBadDefinition(rootType, String.format( "Incompatible types: declared root type (%s) vs %s", rootType, ClassUtil.classNameOf(value))); } /** * Method that will try to find a serializer, either from cache * or by constructing one; but will not return an "unknown" serializer * if this can not be done but rather returns null. * * @return Serializer if one can be found, null if not. */ protected JsonSerializer<Object> _findExplicitUntypedSerializer(Class<?> runtimeType) throws JsonMappingException { // Fast lookup from local lookup thingy works? JsonSerializer<Object> ser = _knownSerializers.untypedValueSerializer(runtimeType); if (ser == null) { // If not, maybe shared map already has it? ser = _serializerCache.untypedValueSerializer(runtimeType); if (ser == null) { ser = _createAndCacheUntypedSerializer(runtimeType); } } /* 18-Sep-2014, tatu: This is unfortunate patch over related change * that pushes creation of "unknown type" serializer deeper down * in BeanSerializerFactory; as a result, we need to "undo" creation * here. */ if (isUnknownTypeSerializer(ser)) { return null; } return ser; } /* /********************************************************** /* Low-level methods for actually constructing and initializing /* serializers /********************************************************** */ /** * Method that will try to construct a value serializer; and if * one is successfully created, cache it for reuse. */ protected JsonSerializer<Object> _createAndCacheUntypedSerializer(Class<?> rawType) throws JsonMappingException { JavaType fullType = _config.constructType(rawType); JsonSerializer<Object

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> return 0; } @Override public int hashCode() { return _name.hashCode(); } @Override public boolean equals(Object o) { if (o == this) return true; if (!ClassUtil.hasClass(o, getClass())) { return false; } VirtualAnnotatedMember other = (VirtualAnnotatedMember) o; return (other._declaringClass == _declaringClass) && other._name.equals(_name); } @Override public String toString() { return "[virtual "+getFullName()+"]"; } }

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>SuffixForScalar(this, gen); } @Override public void serialize(JsonGenerator gen, SerializerProvider provider) throws IOException, JsonProcessingException { gen.writeString(toCanonical()); } /* /********************************************************** /* Methods for sub-classes to use /********************************************************** */ /** * @param trailingSemicolon Whether to add trailing semicolon for non-primitive * (reference) types or not */ protected static StringBuilder _classSignature(Class<?> cls, StringBuilder sb, boolean trailingSemicolon) { if (cls.isPrimitive()) { if (cls == Boolean.TYPE) { sb.append('Z'); } else if (cls == Byte.TYPE) { sb.append('B'); } else if (cls == Short.TYPE) { sb.append('S'); } else if (cls == Character.TYPE) { sb.append('C'); } else if (cls == Integer.TYPE) { sb.append('I'); } else if (cls == Long.TYPE) { sb.append('J'); } else if (cls == Float.TYPE) { sb.append('F'); } else if (cls == Double.TYPE) { sb.append('D'); } else if (cls == Void.TYPE) { sb.append('V'); } else { throw new IllegalStateException("Unrecognized primitive type: "+cls.getName()); } } else { sb.append('L'); String name = cls.getName(); for (int i = 0, len = name.length(); i < len; ++i) { char c = name.charAt(i); if (c == '.') c = '/'; sb.append(c); } if (trailingSemicolon) { sb.append(';'); } } return sb; } /** * Internal helper method used to figure out nominal super-class for * deprecated factory methods / constructors, where we are not given * properly resolved supertype hierarchy. * Will basically give `JavaType` for `java.lang.Object` for classes * other than `java.lafgn.Object`; null for others. * * @since 2.7 */ protected static

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>AnnotatedClass(config, type, r), type, forSerialization, mutatorPrefix); } protected POJOPropertiesCollector collectPropertiesWithBuilder(MapperConfig<?> config, JavaType type, MixInResolver r, boolean forSerialization) { AnnotatedClass ac = _resolveAnnotatedClass(config, type, r); AnnotationIntrospector ai = config.isAnnotationProcessingEnabled() ? config.getAnnotationIntrospector() : null; JsonPOJOBuilder.Value builderConfig = (ai == null) ? null : ai.findPOJOBuilderConfig(ac); String mutatorPrefix = (builderConfig == null) ? JsonPOJOBuilder.DEFAULT_WITH_PREFIX : builderConfig.withPrefix; return constructPropertyCollector(config, ac, type, forSerialization, mutatorPrefix); } /** * Overridable method called for creating {@link POJOPropertiesCollector} instance * to use; override is needed if a custom sub-class is to be used. */ protected POJOPropertiesCollector constructPropertyCollector(MapperConfig<?> config, AnnotatedClass ac, JavaType type, boolean forSerialization, String mutatorPrefix) { return new POJOPropertiesCollector(config, forSerialization, type, ac, mutatorPrefix); } /** * Method called to see if type is one of core JDK types * that we have cached for efficiency. */ protected BasicBeanDescription _findStdTypeDesc(JavaType type) { Class<?> cls = type.getRawClass(); if (cls.isPrimitive()) { if (cls == Boolean.TYPE) { return BOOLEAN_DESC; } if (cls == Integer.TYPE) { return INT_DESC; } if (cls == Long.TYPE) { return LONG_DESC; } } else { if (cls == String.class) { return STRING_DESC; } } return null; } /** * Helper method used to decide whether we can omit introspection * for members (methods, fields, constructors); we may do so for * a limited number of container types JDK provides. */ protected boolean _isStdJDKCollection(JavaType type) { if (!type.isContainerType() || type.isArrayType()) { return false; } Class<?> raw = type.getRaw

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>Class(); String pkgName = ClassUtil.getPackageName(raw); if (pkgName != null) { if (pkgName.startsWith("java.lang") || pkgName.startsWith("java.util")) { /* 23-Sep-2014, tatu: Should we be conservative here (minimal number * of matches), or ambitious? Let's do latter for now. */ if (Collection.class.isAssignableFrom(raw) || Map.class.isAssignableFrom(raw)) { return true; } } } return false; } protected BasicBeanDescription _findStdJdkCollectionDesc(MapperConfig<?> cfg, JavaType type) { if (_isStdJDKCollection(type)) { return BasicBeanDescription.forOtherUse(cfg, type, _resolveAnnotatedClass(cfg, type, cfg)); } return null; } /** * @since 2.9 */ protected AnnotatedClass _resolveAnnotatedClass(MapperConfig<?> config, JavaType type, MixInResolver r) { return AnnotatedClassResolver.resolve(config, type, r); } /** * @since 2.9 */ protected AnnotatedClass _resolveAnnotatedWithoutSuperTypes(MapperConfig<?> config, JavaType type, MixInResolver r) { return AnnotatedClassResolver.resolveWithoutSuperTypes(config, type, r); } }

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> occur but ? v1 : v2.withOverrides(v1); } @Override // since 2.9 public Boolean findMergeInfo(Annotated a) { Boolean b = _primary.findMergeInfo(a); if (b == null) { b = _secondary.findMergeInfo(a); } return b; } @Override @Deprecated // since 2.9 public boolean hasCreatorAnnotation(Annotated a) { return _primary.hasCreatorAnnotation(a) || _secondary.hasCreatorAnnotation(a); } @Override @Deprecated // since 2.9 public JsonCreator.Mode findCreatorBinding(Annotated a) { JsonCreator.Mode mode = _primary.findCreatorBinding(a); if (mode != null) { return mode; } return _secondary.findCreatorBinding(a); } @Override public JsonCreator.Mode findCreatorAnnotation(MapperConfig<?> config, Annotated a) { JsonCreator.Mode mode = _primary.findCreatorAnnotation(config, a); return (mode == null) ? _secondary.findCreatorAnnotation(config, a) : mode; } @Override @Deprecated // since 2.9 public boolean hasAnySetterAnnotation(AnnotatedMethod am) { return _primary.hasAnySetterAnnotation(am) || _secondary.hasAnySetterAnnotation(am); } protected boolean _isExplicitClassOrOb(Object maybeCls, Class<?> implicit) { if ((maybeCls == null) || (maybeCls == implicit)) { return false; } if (maybeCls instanceof Class<?>) { return !ClassUtil.isBogusClass((Class<?>) maybeCls); } return true; } // @since 2.9 protected Object _explicitClassOrOb(Object maybeCls, Class<?> implicit) { if ((maybeCls == null) || (maybeCls == implicit)) { return null; } if ((maybeCls instanceof Class<?>) && ClassUtil.isBogusClass((Class<?>) maybeCls)) { return null; } return maybeCls; } }

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> " +namingClass.getName()+"; expected Class<PropertyNamingStrategy>"); } HandlerInstantiator hi = _config.getHandlerInstantiator(); if (hi != null) { PropertyNamingStrategy pns = hi.namingStrategyInstance(_config, _classDef, namingClass); if (pns != null) { return pns; } } return (PropertyNamingStrategy) ClassUtil.createInstance(namingClass, _config.canOverrideAccessModifiers()); } protected void _updateCreatorProperty(POJOPropertyBuilder prop, List<POJOPropertyBuilder> creatorProperties) { if (creatorProperties != null) { for (int i = 0, len = creatorProperties.size(); i < len; ++i) { if (creatorProperties.get(i).getInternalName().equals(prop.getInternalName())) { creatorProperties.set(i, prop); break; } } } } }

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>) { value = _valueDeserializer.getNullValue(ctxt); } else if (_valueTypeDeserializer != null) { value = _valueDeserializer.deserializeWithType(p, ctxt, _valueTypeDeserializer); } else { // the usual case try { value = _creator.newInstance(bean); } catch (Exception e) { ClassUtil.unwrapAndThrowAsIAE(e, "Failed to instantiate class "+_creator.getDeclaringClass().getName()+", problem: "+e.getMessage()); value = null; } _valueDeserializer.deserialize(p, ctxt, value); } set(bean, value); } @Override public Object deserializeSetAndReturn(JsonParser p, DeserializationContext ctxt, Object instance) throws IOException { return setAndReturn(instance, deserialize(p, ctxt)); } // these are fine with defaults // public final void set(Object instance, Object value) throws IOException { } // public Object setAndReturn(Object instance, Object value) throws IOException { } /* /********************************************************** /* JDK serialization handling /********************************************************** */ // When reading things back, Object readResolve() { return new InnerClassProperty(this, _annotated); } Object writeReplace() { // need to construct a fake instance to support serialization if (_annotated == null) { return new InnerClassProperty(this, new AnnotatedConstructor(null, _creator, null, null)); } return this; } }

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> Should be able to optimize bit more in future... return defaultInstance().constructType(t).getRawClass(); } /* /********************************************************** /* Low-level helper methods /********************************************************** */ /** * Low-level lookup method moved from {@link com.fasterxml.jackson.databind.util.ClassUtil}, * to allow for overriding of lookup functionality in environments like OSGi. * * @since 2.6 */ public Class<?> findClass(String className) throws ClassNotFoundException { if (className.indexOf('.') < 0) { Class<?> prim = _findPrimitive(className); if (prim != null) { return prim; } } // Two-phase lookup: first using context ClassLoader; then default Throwable prob = null; ClassLoader loader = this.getClassLoader(); if (loader == null) { loader = Thread.currentThread().getContextClassLoader(); } if (loader != null) { try { return classForName(className, true, loader); } catch (Exception e) { prob = ClassUtil.getRootCause(e); } } try { return classForName(className); } catch (Exception e) { if (prob == null) { prob = ClassUtil.getRootCause(e); } } ClassUtil.throwIfRTE(prob); throw new ClassNotFoundException(prob.getMessage(), prob); } protected Class<?> classForName(String name, boolean initialize, ClassLoader loader) throws ClassNotFoundException { return Class.forName(name, true, loader); } protected Class<?> classForName(String name) throws ClassNotFoundException { return Class.forName(name); } protected Class<?> _findPrimitive(String className) { if ("int".equals(className)) return Integer.TYPE; if ("long".equals(className)) return Long.TYPE; if ("float".equals(className)) return Float.TYPE; if ("double".equals(className)) return Double.TYPE; if ("boolean".equals(className)) return Boolean.TYPE; if ("byte".equals(className)) return Byte.TYPE; if ("char".equals(className)) return Character.TYPE; if ("short".equals(className)) return Short.TYPE; if ("void".equals(className))

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> superClass, JavaType[] superInterfaces) { if (bindings.isEmpty()) { JavaType result = _findWellKnownSimple(raw); if (result != null) { return result; } } return _newSimpleType(raw, bindings, superClass, superInterfaces); } /** * Factory method that is to create a new {@link SimpleType} with no * checks whatsoever. Default implementation calls the single argument * constructor of {@link SimpleType}. * * @since 2.7 */ protected JavaType _newSimpleType(Class<?> raw, TypeBindings bindings, JavaType superClass, JavaType[] superInterfaces) { return new SimpleType(raw, bindings, superClass, superInterfaces); } protected JavaType _unknownType() { /* 15-Sep-2015, tatu: Prior to 2.7, we constructed new instance for each call. * This may have been due to potential mutability of the instance; but that * should not be issue any more, and creation is somewhat wasteful. So let's * try reusing singleton/flyweight instance. */ return CORE_TYPE_OBJECT; } /** * Helper method called to see if requested, non-generic-parameterized * type is one of common, "well-known" types, instances of which are * pre-constructed and do not need dynamic caching. * * @since 2.7 */ protected JavaType _findWellKnownSimple(Class<?> clz) { if (clz.isPrimitive()) { if (clz == CLS_BOOL) return CORE_TYPE_BOOL; if (clz == CLS_INT) return CORE_TYPE_INT; if (clz == CLS_LONG) return CORE_TYPE_LONG; } else { if (clz == CLS_STRING) return CORE_TYPE_STRING; if (clz == CLS_OBJECT) return CORE_TYPE_OBJECT; // since 2.7 } return null; } /* /********************************************************** /* Actual type resolution, traversal /********************************************************** */ /** * Factory method that can be used if type information is passed * as Java typing returned from <code>

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>rawType == Properties.class) { result = MapType.construct(rawType, bindings, superClass, superInterfaces, CORE_TYPE_STRING, CORE_TYPE_STRING); } // And then check what flavor of type we got. Start by asking resolved // super-type if refinement is all that is needed? else if (superClass != null) { result = superClass.refine(rawType, bindings, superClass, superInterfaces); } // if not, perhaps we are now resolving a well-known class or interface? if (result == null) { result = _fromWellKnownClass(context, rawType, bindings, superClass, superInterfaces); if (result == null) { result = _fromWellKnownInterface(context, rawType, bindings, superClass, superInterfaces); if (result == null) { // but if nothing else, "simple" class for now: result = _newSimpleType(rawType, bindings, superClass, superInterfaces); } } } } context.resolveSelfReferences(result); // 16-Jul-2016, tatu: [databind#1302] is solved different way, but ideally we shouldn't // cache anything with partially resolved `ResolvedRecursiveType`... so maybe improve if (!result.hasHandlers()) { _typeCache.putIfAbsent(key, result); // cache object syncs } return result; } protected JavaType _resolveSuperClass(ClassStack context, Class<?> rawType, TypeBindings parentBindings) { Type parent = ClassUtil.getGenericSuperclass(rawType); if (parent == null) { return null; } return _fromAny(context, parent, parentBindings); } protected JavaType[] _resolveSuperInterfaces(ClassStack context, Class<?> rawType, TypeBindings parentBindings) { Type[] types = ClassUtil.getGenericInterfaces(rawType); if (types == null || types.length == 0) { return NO_TYPES; } int len = types.length; JavaType[] resolved = new JavaType[len]; for (int i = 0; i < len; ++i) { Type type = types[i]; resolved[i] = _fromAny(

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>.collections.functors.InstantiateTransformer"); s.add("org.apache.commons.collections4.functors.InvokerTransformer"); s.add("org.apache.commons.collections4.functors.InstantiateTransformer"); s.add("org.codehaus.groovy.runtime.ConvertedClosure"); s.add("org.codehaus.groovy.runtime.MethodClosure"); s.add("org.springframework.beans.factory.ObjectFactory"); s.add("com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl"); s.add("org.apache.xalan.xsltc.trax.TemplatesImpl"); DEFAULT_NO_DESER_CLASS_NAMES = Collections.unmodifiableSet(s); } /** * Set of class names of types that are never to be deserialized. * * @since 2.8.9 */ protected Set<String> _cfgIllegalClassNames = DEFAULT_NO_DESER_CLASS_NAMES; /* /********************************************************** /* Life-cycle /********************************************************** */ /** * Globally shareable thread-safe instance which has no additional custom deserializers * registered */ public final static BeanDeserializerFactory instance = new BeanDeserializerFactory( new DeserializerFactoryConfig()); public BeanDeserializerFactory(DeserializerFactoryConfig config) { super(config); } /** * Method used by module registration functionality, to construct a new bean * deserializer factory * with different configuration settings. */ @Override public DeserializerFactory withConfig(DeserializerFactoryConfig config) { if (_factoryConfig == config) { return this; } /* 22-Nov-2010, tatu: Handling of subtypes is tricky if we do immutable-with-copy-ctor; * and we pretty much have to here either choose between losing subtype instance * when registering additional deserializers, or losing deserializers. * Instead, let's actually just throw an error if this method is called when subtype * has not properly overridden this method; this to indicate problem as soon as possible. */ ClassUtil.verifyMustOverride(BeanDeserializerFactory.class, this, "withConfig"); return new BeanDeserializerFactory(config); } /* /********************************************************** /*

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> DeserializerFactory API implementation /********************************************************** */ /** * Method that {@link DeserializerCache}s call to create a new * deserializer for types other than Collections, Maps, arrays and * enums. */ @Override public JsonDeserializer<Object> createBeanDeserializer(DeserializationContext ctxt, JavaType type, BeanDescription beanDesc) throws JsonMappingException { final DeserializationConfig config = ctxt.getConfig(); // We may also have custom overrides: JsonDeserializer<Object> custom = _findCustomBeanDeserializer(type, config, beanDesc); if (custom != null) { return custom; } /* One more thing to check: do we have an exception type * (Throwable or its sub-classes)? If so, need slightly * different handling. */ if (type.isThrowable()) { return buildThrowableDeserializer(ctxt, type, beanDesc); } /* Or, for abstract types, may have alternate means for resolution * (defaulting, materialization) */ // 29-Nov-2015, tatu: Also, filter out calls to primitive types, they are // not something we could materialize anything for if (type.isAbstract() && !type.isPrimitive() && !type.isEnumType()) { // Let's make it possible to materialize abstract types. JavaType concreteType = materializeAbstractType(ctxt, type, beanDesc); if (concreteType != null) { /* important: introspect actual implementation (abstract class or * interface doesn't have constructors, for one) */ beanDesc = config.introspect(concreteType); return buildBeanDeserializer(ctxt, concreteType, beanDesc); } } // Otherwise, may want to check handlers for standard types, from superclass: @SuppressWarnings("unchecked") JsonDeserializer<Object> deser = (JsonDeserializer<Object>) findStdDeserializer(ctxt, type, beanDesc); if (deser != null) { return deser; } // Otherwise: could the class be a Bean class? If not, bail out if (!isPotentialBeanType(type.getRawClass())) { return null; } // For checks like [databind#1599] checkIllegalTypes(ctxt, type, beanDesc); // Use generic

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>config.canOverrideAccessModifiers()) { ClassUtil.checkAndFixAccess(buildMethod.getMember(), config.isEnabled(MapperFeature.OVERRIDE_PUBLIC_ACCESS_MODIFIERS)); } } builder.setPOJOBuilder(buildMethod, builderConfig); // this may give us more information... if (_factoryConfig.hasDeserializerModifiers()) { for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { builder = mod.updateBuilder(config, builderDesc, builder); } } JsonDeserializer<?> deserializer = builder.buildBuilderBased( valueType, buildMethodName); // [JACKSON-440]: may have modifier(s) that wants to modify or replace serializer we just built: if (_factoryConfig.hasDeserializerModifiers()) { for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { deserializer = mod.modifyDeserializer(config, builderDesc, deserializer); } } return (JsonDeserializer<Object>) deserializer; } protected void addObjectIdReader(DeserializationContext ctxt, BeanDescription beanDesc, BeanDeserializerBuilder builder) throws JsonMappingException { ObjectIdInfo objectIdInfo = beanDesc.getObjectIdInfo(); if (objectIdInfo == null) { return; } Class<?> implClass = objectIdInfo.getGeneratorType(); JavaType idType; SettableBeanProperty idProp; ObjectIdGenerator<?> gen; ObjectIdResolver resolver = ctxt.objectIdResolverInstance(beanDesc.getClassInfo(), objectIdInfo); // Just one special case: Property-based generator is trickier if (implClass == ObjectIdGenerators.PropertyGenerator.class) { // most special one, needs extra work PropertyName propName = objectIdInfo.getPropertyName(); idProp = builder.findProperty(propName); if (idProp == null) { throw new IllegalArgumentException("Invalid Object Id definition for " +beanDesc.getBeanClass().getName()+": can not find property with name '"+propName+"'"); } idType = idProp.getType(); gen = new PropertyBasedObjectIdGenerator(objectIdInfo.getScope()); } else { JavaType type = ctxt.constructType(implClass); idType = ctxt.getTypeFactory().findTypeParameters(type, ObjectIdGenerator.class)[0]; id

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> { final AnnotatedMethod getter = propDef.getGetter(); JavaType type = resolveMemberAndTypeAnnotations(ctxt, getter, getter.getType()); TypeDeserializer typeDeser = type.getTypeHandler(); SettableBeanProperty prop = new SetterlessProperty(propDef, type, typeDeser, beanDesc.getClassAnnotations(), getter); JsonDeserializer<?> deser = findDeserializerFromAnnotation(ctxt, getter); if (deser == null) { deser = type.getValueHandler(); } if (deser != null) { deser = ctxt.handlePrimaryContextualization(deser, prop, type); prop = prop.withValueDeserializer(deser); } return prop; } /* /********************************************************** /* Helper methods for Bean deserializer, other /********************************************************** */ /** * Helper method used to skip processing for types that we know * can not be (i.e. are never consider to be) beans: * things like primitives, Arrays, Enums, and proxy types. *<p> * Note that usually we shouldn't really be getting these sort of * types anyway; but better safe than sorry. */ protected boolean isPotentialBeanType(Class<?> type) { String typeStr = ClassUtil.canBeABeanType(type); if (typeStr != null) { throw new IllegalArgumentException("Can not deserialize Class "+type.getName()+" (of type "+typeStr+") as a Bean"); } if (ClassUtil.isProxyType(type)) { throw new IllegalArgumentException("Can not deserialize Proxy class "+type.getName()+" as a Bean"); } /* also: can't deserialize some local classes: static are ok; in-method not; * other non-static inner classes are ok */ typeStr = ClassUtil.isLocalType(type, true); if (typeStr != null) { throw new IllegalArgumentException("Can not deserialize Class "+type.getName()+" (of type "+typeStr+") as a Bean"); } return true; } /** * Helper method that will check whether given raw type is marked as always ignorable * (for purpose of ignoring properties with type) */ protected boolean isIgnorableType(DeserializationConfig config, BeanPropertyDefinition propDef, Class<?> type, Map<Class<?>,

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>Boolean> ignoredTypes) { Boolean status = ignoredTypes.get(type); if (status != null) { return status.booleanValue(); } // 22-Oct-2016, tatu: Slight check to skip primitives, String if ((type == String.class) || type.isPrimitive()) { status = Boolean.FALSE; } else { // 21-Apr-2016, tatu: For 2.8, can specify config overrides status = config.getConfigOverride(type).getIsIgnoredType(); if (status == null) { BeanDescription desc = config.introspectClassAnnotations(type); status = config.getAnnotationIntrospector().isIgnorableType(desc.getClassInfo()); // We default to 'false', i.e. not ignorable if (status == null) { status = Boolean.FALSE; } } } ignoredTypes.put(type, status); return status.booleanValue(); } /** * @since 2.8.9 */ protected void checkIllegalTypes(DeserializationContext ctxt, JavaType type, BeanDescription beanDesc) throws JsonMappingException { // There are certain nasty classes that could cause problems, mostly // via default typing -- catch them here. String full = type.getRawClass().getName(); if (_cfgIllegalClassNames.contains(full)) { ctxt.reportBadTypeDefinition(beanDesc, "Illegal type (%s) to deserialize: prevented for security reasons", full); } } }

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>(); } protected DefaultSerializerProvider(SerializerProvider src, SerializationConfig config,SerializerFactory f) { super(src, config, f); } protected DefaultSerializerProvider(DefaultSerializerProvider src) { super(src); } /** * Method that sub-classes need to implement: used to create a non-blueprint instances * from the blueprint. * This is needed to retain state during serialization. */ public abstract DefaultSerializerProvider createInstance(SerializationConfig config, SerializerFactory jsf); /** * Method needed to ensure that {@link ObjectMapper#copy} will work * properly; specifically, that caches are cleared, but settings * will otherwise remain identical; and that no sharing of state * occurs. * * @since 2.5 */ public DefaultSerializerProvider copy() { throw new IllegalStateException("DefaultSerializerProvider sub-class not overriding copy()"); } /* /********************************************************** /* Abstract method impls, factory methods /********************************************************** */ @Override public JsonSerializer<Object> serializerInstance(Annotated annotated, Object serDef) throws JsonMappingException { if (serDef == null) { return null; } JsonSerializer<?> ser; if (serDef instanceof JsonSerializer) { ser = (JsonSerializer<?>) serDef; } else { // Alas, there's no way to force return type of "either class // X or Y" -- need to throw an exception after the fact if (!(serDef instanceof Class)) { reportBadDefinition(annotated.getType(), "AnnotationIntrospector returned serializer definition of type " +serDef.getClass().getName()+"; expected type JsonSerializer or Class<JsonSerializer> instead"); } Class<?> serClass = (Class<?>)serDef; // there are some known "no class" markers to consider too: if (serClass == JsonSerializer.None.class || ClassUtil.isBogusClass(serClass)) { return null; } if (!JsonSerializer.class.isAssignableFrom(serClass)) { reportBadDefinition(annotated.getType(), "AnnotationIntrospector returned Class " +serClass.getName()+"; expected Class<JsonSerializer>"); } HandlerInstantiator hi = _config.getHandlerInstantiator(); ser = (hi == null) ? null : hi.serializerInstance(_config

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>, annotated, serClass); if (ser == null) { ser = (JsonSerializer<?>) ClassUtil.createInstance(serClass, _config.canOverrideAccessModifiers()); } } return (JsonSerializer<Object>) _handleResolvable(ser); } @Override public Object includeFilterInstance(BeanPropertyDefinition forProperty, Class<?> filterClass) { if (filterClass == null) { return null; } HandlerInstantiator hi = _config.getHandlerInstantiator(); Object filter = (hi == null) ? null : hi.includeFilterInstance(_config, forProperty, filterClass); if (filter == null) { filter = ClassUtil.createInstance(filterClass, _config.canOverrideAccessModifiers()); } return filter; } @Override public boolean includeFilterSuppressNulls(Object filter) throws JsonMappingException { if (filter == null) { return true; } // should let filter decide what to do with nulls: // But just case, let's handle unexpected (from our perspective) problems explicitly try { return filter.equals(null); } catch (Throwable t) { String msg = String.format( "Problem determining whether filter of type '%s' should filter out `null` values: (%s) %s", filter.getClass().getName(), t.getClass().getName(), t.getMessage()); reportBadDefinition(filter.getClass(), msg, t); return false; // never gets here } } /* /********************************************************** /* Object Id handling /********************************************************** */ @Override public WritableObjectId findObjectId(Object forPojo, ObjectIdGenerator<?> generatorType) { if (_seenObjectIds == null) { _seenObjectIds = _createObjectIdMap(); } else { WritableObjectId oid = _seenObjectIds.get(forPojo); if (oid != null) { return oid; } } // Not seen yet; must add an entry, return it. For that, we need generator ObjectIdGenerator<?> generator = null; if (_objectIdGenerators == null) { _objectIdGenerators = new ArrayList<ObjectIdGenerator<?>>(8); } else { for (int i = 0, len = _objectIdGenerators.size(); i <

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>rospect(type); // Ok, so: can we find T(String) constructor? Constructor<?> ctor = beanDesc.findSingleArgConstructor(String.class); if (ctor != null) { if (config.canOverrideAccessModifiers()) { ClassUtil.checkAndFixAccess(ctor, config.isEnabled(MapperFeature.OVERRIDE_PUBLIC_ACCESS_MODIFIERS)); } return new StdKeyDeserializer.StringCtorKeyDeserializer(ctor); } /* or if not, "static T valueOf(String)" (or equivalent marked * with @JsonCreator annotation?) */ Method m = beanDesc.findFactoryMethod(String.class); if (m != null){ if (config.canOverrideAccessModifiers()) { ClassUtil.checkAndFixAccess(m, config.isEnabled(MapperFeature.OVERRIDE_PUBLIC_ACCESS_MODIFIERS)); } return new StdKeyDeserializer.StringFactoryKeyDeserializer(m); } // nope, no such luck... return null; } /* /********************************************************** /* KeyDeserializers implementation /********************************************************** */ @Override public KeyDeserializer findKeyDeserializer(JavaType type, DeserializationConfig config, BeanDescription beanDesc) throws JsonMappingException { Class<?> raw = type.getRawClass(); // 23-Apr-2013, tatu: Map primitive types, just in case one was given if (raw.isPrimitive()) { raw = ClassUtil.wrapperType(raw); } return StdKeyDeserializer.forType(raw); } }

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> { return _method.invoke(pojo, (Object[]) null); } catch (IllegalAccessException | InvocationTargetException e) { throw new IllegalArgumentException("Failed to getValue() with method " +getFullName()+": "+e.getMessage(), e); } } /* /***************************************************** /* Extended API, generic /***************************************************** */ @Override public String getFullName() { return String.format("%s(%d params)", super.getFullName(), getParameterCount()); } public Class<?>[] getRawParameterTypes() { if (_paramClasses == null) { _paramClasses = _method.getParameterTypes(); } return _paramClasses; } @Deprecated // since 2.7 public Type[] getGenericParameterTypes() { return _method.getGenericParameterTypes(); } public Class<?> getRawReturnType() { return _method.getReturnType(); } /** * Helper method that can be used to check whether method returns * a value or not; if return type declared as <code>void</code>, returns * false, otherwise true * * @since 2.4 */ public boolean hasReturnType() { Class<?> rt = getRawReturnType(); return (rt != Void.TYPE && rt != Void.class); } /* /******************************************************** /* Other /******************************************************** */ @Override public String toString() { return "[method "+getFullName()+"]"; } @Override public int hashCode() { return _method.getName().hashCode(); } @Override public boolean equals(Object o) { if (o == this) return true; return ClassUtil.hasClass(o, getClass()) && (((AnnotatedMethod) o)._method == _method); } /* /********************************************************** /* JDK serialization handling /********************************************************** */ Object writeReplace() { return new AnnotatedMethod(new Serialization(_method)); } Object readResolve() { Class<?> clazz = _serialization.clazz; try { Method m = clazz.getDeclaredMethod(_serialization.name, _serialization.args); // 06-Oct-2012, tatu: Has "lost" its security override, may need to force back if (!m.isAccessible()) { ClassUtil.checkAndFixAccess(m

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> { return withConfig(_factoryConfig.withSerializerModifier(modifier)); } /* /********************************************************** /* SerializerFactory impl /********************************************************** */ // Implemented by sub-classes @Override public abstract JsonSerializer<Object> createSerializer(SerializerProvider prov, JavaType type) throws JsonMappingException; @Override @SuppressWarnings("unchecked") public JsonSerializer<Object> createKeySerializer(SerializationConfig config, JavaType keyType, JsonSerializer<Object> defaultImpl) { // We should not need any member method info; at most class annotations for Map type // ... at least, not here. BeanDescription beanDesc = config.introspectClassAnnotations(keyType.getRawClass()); JsonSerializer<?> ser = null; // Minor optimization: to avoid constructing beanDesc, bail out if none registered if (_factoryConfig.hasKeySerializers()) { // Only thing we have here are module-provided key serializers: for (Serializers serializers : _factoryConfig.keySerializers()) { ser = serializers.findSerializer(config, keyType, beanDesc); if (ser != null) { break; } } } if (ser == null) { ser = defaultImpl; if (ser == null) { ser = StdKeySerializers.getStdKeySerializer(config, keyType.getRawClass(), false); // As per [databind#47], also need to support @JsonValue if (ser == null) { beanDesc = config.introspect(keyType); AnnotatedMember am = beanDesc.findJsonValueAccessor(); if (am != null) { final Class<?> rawType = am.getRawType(); JsonSerializer<?> delegate = StdKeySerializers.getStdKeySerializer(config, rawType, true); if (config.canOverrideAccessModifiers()) { ClassUtil.checkAndFixAccess(am.getMember(), config.isEnabled(MapperFeature.OVERRIDE_PUBLIC_ACCESS_MODIFIERS)); } ser = new JsonValueSerializer(am, delegate); } else { ser = StdKeySerializers.getFallbackKeySerializer(config, keyType.getRawClass()); } } } } // [databind#120]: Allow post-processing if (_factoryConfig.hasSerializerModifiers()) { for (BeanSerializerModifier mod

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>serClass != null) { // 07-Jan-2017, tatu: Should never fail (since we control constructors), // but if it does will throw `IllegalArgumentException` with description, // which we could catch, re-title. return ClassUtil.createInstance(serClass, false); } } return ser; } /** * Method called to see if one of primary per-class annotations * (or related, like implementing of {@link JsonSerializable}) * determines the serializer to use. *<p> * Currently handles things like: *<ul> * <li>If type implements {@link JsonSerializable}, use that * </li> * <li>If type has {@link com.fasterxml.jackson.annotation.JsonValue} annotation (or equivalent), build serializer * based on that property * </li> *</ul> * * @since 2.0 */ protected final JsonSerializer<?> findSerializerByAnnotations(SerializerProvider prov, JavaType type, BeanDescription beanDesc) throws JsonMappingException { Class<?> raw = type.getRawClass(); // First: JsonSerializable? if (JsonSerializable.class.isAssignableFrom(raw)) { return SerializableSerializer.instance; } // Second: @JsonValue for any type AnnotatedMember valueAccessor = beanDesc.findJsonValueAccessor(); if (valueAccessor != null) { if (prov.canOverrideAccessModifiers()) { ClassUtil.checkAndFixAccess(valueAccessor.getMember(), prov.isEnabled(MapperFeature.OVERRIDE_PUBLIC_ACCESS_MODIFIERS)); } JsonSerializer<Object> ser = findSerializerFromAnnotation(prov, valueAccessor); return new JsonValueSerializer(valueAccessor, ser); } // No well-known annotations... return null; } /** * Method for checking if we can determine serializer to use based on set of * known primary types, checking for set of known base types (exact matches * having been compared against with <code>findSerializerByLookup</code>). * This does not include "secondary" interfaces, but * mostly concrete or abstract base classes. */ protected final JsonSerializer<?> findSerializerByPrimaryType(SerializerProvider prov, JavaType type, BeanDescription beanDesc, boolean staticTyping

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> if (ser == null) { ser = findSerializerByAnnotations(prov, type, beanDesc); // (2) Annotations if (ser == null) { // We may also want to use serialize Collections "as beans", if (and only if) // this is specified with `@JsonFormat(shape=Object)` JsonFormat.Value format = beanDesc.findExpectedFormat(null); if ((format != null) && format.getShape() == JsonFormat.Shape.OBJECT) { return null; } Class<?> raw = type.getRawClass(); if (EnumSet.class.isAssignableFrom(raw)) { // this may or may not be available (Class doesn't; type of field/method does) JavaType enumType = type.getContentType(); // and even if nominally there is something, only use if it really is enum if (!enumType.isEnumType()) { enumType = null; } ser = buildEnumSetSerializer(enumType); } else { Class<?> elementRaw = type.getContentType().getRawClass(); if (isIndexedList(raw)) { if (elementRaw == String.class) { // [JACKSON-829] Must NOT use if we have custom serializer if (ClassUtil.isJacksonStdImpl(elementValueSerializer)) { ser = IndexedStringListSerializer.instance; } } else { ser = buildIndexedListSerializer(type.getContentType(), staticTyping, elementTypeSerializer, elementValueSerializer); } } else if (elementRaw == String.class) { // [JACKSON-829] Must NOT use if we have custom serializer if (ClassUtil.isJacksonStdImpl(elementValueSerializer)) { ser = StringCollectionSerializer.instance; } } if (ser == null) { ser = buildCollectionSerializer(type.getContentType(), staticTyping, elementTypeSerializer, elementValueSerializer); } } } } // [databind#120]: Allow post-processing if (_factoryConfig.hasSerializerModifiers()) { for (BeanSerializerModifier mod : _factoryConfig.serializerModifiers()) { ser = mod.modifyCollectionSerializer(config, type, beanDesc, ser); } } return ser; }

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> (Serializers serializers : customSerializers()) { // (1) Custom ser = serializers.findArraySerializer(config, type, beanDesc, elementTypeSerializer, elementValueSerializer); if (ser != null) { break; } } if (ser == null) { Class<?> raw = type.getRawClass(); // Important: do NOT use standard serializers if non-standard element value serializer specified if (elementValueSerializer == null || ClassUtil.isJacksonStdImpl(elementValueSerializer)) { if (String[].class == raw) { ser = StringArraySerializer.instance; } else { // other standard types? ser = StdArraySerializers.findStandardImpl(raw); } } if (ser == null) { ser = new ObjectArraySerializer(type.getContentType(), staticTyping, elementTypeSerializer, elementValueSerializer); } } // [databind#120]: Allow post-processing if (_factoryConfig.hasSerializerModifiers()) { for (BeanSerializerModifier mod : _factoryConfig.serializerModifiers()) { ser = mod.modifyArraySerializer(config, type, beanDesc, ser); } } return ser; } /* /********************************************************** /* Factory methods, for non-container types /********************************************************** */ /** * @since 2.5 */ protected JsonSerializer<?> buildIteratorSerializer(SerializationConfig config, JavaType type, BeanDescription beanDesc, boolean staticTyping, JavaType valueType) throws JsonMappingException { return new IteratorSerializer(valueType, staticTyping, createTypeSerializer(config, valueType)); } /** * @since 2.5 */ protected JsonSerializer<?> buildIterableSerializer(SerializationConfig config, JavaType type, BeanDescription beanDesc, boolean staticTyping, JavaType valueType) throws JsonMappingException { return new IterableSerializer(valueType, staticTyping, createTypeSerializer(config, valueType)); } protected JsonSerializer<?> buildEnumSerializer(SerializationConfig config, JavaType type, BeanDescription beanDesc) throws JsonMappingException { /* As per [databind#24], may want to use alternate shape, serialize as JSON Object. * Challenge here is that EnumSerializer does not know how to produce * POJO style serialization, so we must

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> // a name at all, and need to be skipped if (name.length() == 0 && properties[i].getInjectableValueId() != null) { continue; } Integer old = names.put(name, Integer.valueOf(i)); if (old != null) { throw new IllegalArgumentException(String.format( "Duplicate creator property \"%s\" (index %s vs %d)", name, old, i)); } } } _propertyBasedArgs = properties; } } public void addIncompeteParameter(AnnotatedParameter parameter) { if (_incompleteParameter == null) { _incompleteParameter = parameter; } } /* /********************************************************** /* Accessors /********************************************************** */ /** * @since 2.1 */ public boolean hasDefaultCreator() { return _creators[C_DEFAULT] != null; } /** * @since 2.6 */ public boolean hasDelegatingCreator() { return _creators[C_DELEGATE] != null; } /** * @since 2.6 */ public boolean hasPropertyBasedCreator() { return _creators[C_PROPS] != null; } /* /********************************************************** /* Helper methods /********************************************************** */ private JavaType _computeDelegateType(AnnotatedWithParams creator, SettableBeanProperty[] delegateArgs) { if (!_hasNonDefaultCreator || (creator == null)) { return null; } // need to find type... int ix = 0; if (delegateArgs != null) { for (int i = 0, len = delegateArgs.length; i < len; ++i) { if (delegateArgs[i] == null) { // marker for delegate itself ix = i; break; } } } return creator.getParameterType(ix); } private <T extends AnnotatedMember> T _fixAccess(T member) { if (member != null && _canFixAccess) { ClassUtil.checkAndFixAccess((Member) member.getAnnotated(), _forceAccess); } return member; } /** * @return True if specified Creator is to be used */ protected boolean verifyNonDup(Annotated

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>package com.fasterxml.jackson.databind; import com.fasterxml.jackson.core.SerializableString; import com.fasterxml.jackson.core.io.SerializedString; import com.fasterxml.jackson.core.util.InternCache; import com.fasterxml.jackson.databind.cfg.MapperConfig; import com.fasterxml.jackson.databind.util.ClassUtil; /** * Simple value class used for containing names of properties as defined * by annotations (and possibly other configuration sources). * * @since 2.1 */ public class PropertyName implements java.io.Serializable { private static final long serialVersionUID = 1L; // 2.5 private final static String _USE_DEFAULT = ""; private final static String _NO_NAME = ""; /** * Special placeholder value that indicates that name to use should be * based on the standard heuristics. This can be different from returning * null, as null means "no information available, whereas this value * indicates explicit defaulting. */ public final static PropertyName USE_DEFAULT = new PropertyName(_USE_DEFAULT, null); /** * Special placeholder value that indicates that there is no name associated. * Exact semantics to use (if any) depend on actual annotation in use, but * commonly this value disables behavior for which name would be needed. */ public final static PropertyName NO_NAME = new PropertyName(new String(_NO_NAME), null); /** * Basic name of the property. */ protected final String _simpleName; /** * Additional namespace, for formats that have such concept (JSON * does not, XML does, for example). */ protected final String _namespace; /** * Lazily-constructed efficient representation of the simple name. *<p> * NOTE: not defined as volatile to avoid performance problem with * concurrent access in multi-core environments; due to statelessness * of {@link SerializedString} at most leads to multiple instantiations. * * @since 2.4 */ protected SerializableString _encodedSimple; public PropertyName(String simpleName) { this(simpleName, null); } public PropertyName(String simpleName, String namespace) { _simpleName = ClassUtil.nonNullString(simpleName

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> cdClass); } } if (cd != null) { type = type.withContentValueHandler(cd); } } } } // And after handlers, possible type refinements // (note: could possibly avoid this if explicit deserializer was invoked?) type = intr.refineDeserializationType(ctxt.getConfig(), a, type); return type; } /* /********************************************************** /* Helper methods, other /********************************************************** */ /** * Helper method used to prevent both caching and cache lookups for structured * types that have custom value handlers * * @since 2.4.6 */ private boolean _hasCustomValueHandler(JavaType t) { if (t.isContainerType()) { JavaType ct = t.getContentType(); if (ct != null) { return (ct.getValueHandler() != null) || (ct.getTypeHandler() != null); } } return false; } private Class<?> _verifyAsClass(Object src, String methodName, Class<?> noneClass) { if (src == null) { return null; } if (!(src instanceof Class)) { throw new IllegalStateException("AnnotationIntrospector."+methodName+"() returned value of type "+src.getClass().getName()+": expected type JsonSerializer or Class<JsonSerializer> instead"); } Class<?> cls = (Class<?>) src; if (cls == noneClass || ClassUtil.isBogusClass(cls)) { return null; } return cls; } /* /********************************************************** /* Overridable error reporting methods /********************************************************** */ protected JsonDeserializer<Object> _handleUnknownValueDeserializer(DeserializationContext ctxt, JavaType type) throws JsonMappingException { // Let's try to figure out the reason, to give better error messages Class<?> rawClass = type.getRawClass(); if (!ClassUtil.isConcrete(rawClass)) { return ctxt.reportBadDefinition(type, "Can not find a Value deserializer for abstract type "+type); } return ctxt.reportBadDefinition(type, "Can not find a Value deserializer for type "+type); } protected KeyDeserializer _handleUnknownKeyDeserializer(DeserializationContext ctxt, JavaType type) throws JsonMappingException { return ctxt

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> = null; _delegateSerializer = null; } @SuppressWarnings("unchecked") public StdDelegatingSerializer(Converter<Object,?> converter, JavaType delegateType, JsonSerializer<?> delegateSerializer) { super(delegateType); _converter = converter; _delegateType = delegateType; _delegateSerializer = (JsonSerializer<Object>) delegateSerializer; } /** * Method used for creating resolved contextual instances. Must be * overridden when sub-classing. */ protected StdDelegatingSerializer withDelegate(Converter<Object,?> converter, JavaType delegateType, JsonSerializer<?> delegateSerializer) { ClassUtil.verifyMustOverride(StdDelegatingSerializer.class, this, "withDelegate"); return new StdDelegatingSerializer(converter, delegateType, delegateSerializer); } /* /********************************************************** /* Contextualization /********************************************************** */ @Override public void resolve(SerializerProvider provider) throws JsonMappingException { if ((_delegateSerializer != null) && (_delegateSerializer instanceof ResolvableSerializer)) { ((ResolvableSerializer) _delegateSerializer).resolve(provider); } } @Override public JsonSerializer<?> createContextual(SerializerProvider provider, BeanProperty property) throws JsonMappingException { JsonSerializer<?> delSer = _delegateSerializer; JavaType delegateType = _delegateType; if (delSer == null) { // Otherwise, need to locate serializer to delegate to. For that we need type information... if (delegateType == null) { delegateType = _converter.getOutputType(provider.getTypeFactory()); } // 02-Apr-2015, tatu: For "dynamic case", where type is only specified as // java.lang.Object (or missing generic), [databind#731] if (!delegateType.isJavaLangObject()) { delSer = provider.findValueSerializer(delegateType); } } if (delSer instanceof ContextualSerializer) { delSer = provider.handleSecondaryContextualization(delSer, property); } if (delSer == _delegateSerializer && delegateType == _delegateType) { return this; } return withDelegate(_converter, delegateType, delSer); } /* /********************************************************** /* Accessors /********************************************************** */ protected Converter<Object

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> value) throws IllegalArgumentException { try { _field.set(pojo, value); } catch (IllegalAccessException e) { throw new IllegalArgumentException("Failed to setValue() for field " +getFullName()+": "+e.getMessage(), e); } } @Override public Object getValue(Object pojo) throws IllegalArgumentException { try { return _field.get(pojo); } catch (IllegalAccessException e) { throw new IllegalArgumentException("Failed to getValue() for field " +getFullName()+": "+e.getMessage(), e); } } /* /********************************************************** /* Extended API, generic /********************************************************** */ public int getAnnotationCount() { return _annotations.size(); } /** * @since 2.6 */ public boolean isTransient() { return Modifier.isTransient(getModifiers()); } @Override public int hashCode() { return _field.getName().hashCode(); } @Override public boolean equals(Object o) { if (o == this) return true; return ClassUtil.hasClass(o, getClass()) && (((AnnotatedField) o)._field == _field); } @Override public String toString() { return "[field "+getFullName()+"]"; } /* /********************************************************** /* JDK serialization handling /********************************************************** */ Object writeReplace() { return new AnnotatedField(new Serialization(_field)); } Object readResolve() { Class<?> clazz = _serialization.clazz; try { Field f = clazz.getDeclaredField(_serialization.name); // 06-Oct-2012, tatu: Has "lost" its security override, may need to force back if (!f.isAccessible()) { ClassUtil.checkAndFixAccess(f, false); } return new AnnotatedField(null, f, null); } catch (Exception e) { throw new IllegalArgumentException("Could not find method '"+_serialization.name +"' from Class '"+clazz.getName()); } } /** * Helper class that is used as the workaround to persist * Field references. It basically just stores declaring class * and field name. */ private final static class Serialization implements java.io.Serializable { private static final long serialVersionUID = 1L; protected Class

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>sortKeys); } /** * Mutant factory for constructing an instance with different inclusion strategy * for content (Map values). * * @since 2.9 */ public MapSerializer withContentInclusion(Object suppressableValue, boolean suppressNulls) { if ((suppressableValue == _suppressableValue) && (suppressNulls == _suppressNulls)) { return this; } _ensureOverride("withContentInclusion"); return new MapSerializer(this, _valueTypeSerializer, suppressableValue, suppressNulls); } /** * @since 2.8 */ public static MapSerializer construct(Set<String> ignoredEntries, JavaType mapType, boolean staticValueType, TypeSerializer vts, JsonSerializer<Object> keySerializer, JsonSerializer<Object> valueSerializer, Object filterId) { JavaType keyType, valueType; if (mapType == null) { keyType = valueType = UNSPECIFIED_TYPE; } else { keyType = mapType.getKeyType(); valueType = mapType.getContentType(); } // If value type is final, it's same as forcing static value typing: if (!staticValueType) { staticValueType = (valueType != null && valueType.isFinal()); } else { // also: Object.class can not be handled as static, ever if (valueType.getRawClass() == Object.class) { staticValueType = false; } } MapSerializer ser = new MapSerializer(ignoredEntries, keyType, valueType, staticValueType, vts, keySerializer, valueSerializer); if (filterId != null) { ser = ser.withFilterId(filterId); } return ser; } /** * @since 2.9 */ protected void _ensureOverride(String method) { ClassUtil.verifyMustOverride(MapSerializer.class, this, method); } /** * @since 2.5 */ @Deprecated // since 2.9 protected void _ensureOverride() { _ensureOverride("N/A"); } /* /********************************************************** /* Deprecated creators /********************************************************** */ /** * @since 2.5 * @deprecated // since 2.9 */ @Deprecated

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>Mask(); // @since 2.9 protected final static int F_MASK_ACCEPT_ARRAYS = DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS.getMask() | DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT.getMask(); /** * Type of values this deserializer handles: sometimes * exact types, other time most specific supertype of * types deserializer handles (which may be as generic * as {@link Object} in some case) */ final protected Class<?> _valueClass; protected StdDeserializer(Class<?> vc) { _valueClass = vc; } protected StdDeserializer(JavaType valueType) { _valueClass = valueType.getRawClass(); } /** * Copy-constructor for sub-classes to use, most often when creating * new instances for {@link com.fasterxml.jackson.databind.deser.ContextualDeserializer}. * * @since 2.5 */ protected StdDeserializer(StdDeserializer<?> src) { _valueClass = src._valueClass; } /* /********************************************************** /* Accessors /********************************************************** */ @Override public Class<?> handledType() { return _valueClass; } /* /********************************************************** /* Extended API /********************************************************** */ /** * @deprecated Since 2.3 use {@link #handledType} instead */ @Deprecated public final Class<?> getValueClass() { return _valueClass; } /** * Exact structured type this deserializer handles, if known. *<p> * Default implementation just returns null. */ public JavaType getValueType() { return null; } /** * Method that can be called to determine if given deserializer is the default * deserializer Jackson uses; as opposed to a custom deserializer installed by * a module or calling application. Determination is done using * {@link JacksonStdImpl} annotation on deserializer class. */ protected boolean isDefaultDeserializer(JsonDeserializer<?> deserializer) { return ClassUtil.isJacksonStdImpl(deserializer); } protected boolean isDefaultKeyDeserializer(KeyDeserializer keyDeser) { return ClassUtil.isJacksonStdImpl(keyDeser); } /* /********************************************************** /* Partial JsonDeserializer implementation

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> simply calls * {@link #deserialize(JsonParser, DeserializationContext)}, * but handling may be overridden. * * @since 2.9 */ protected T _deserializeWrappedValue(JsonParser p, DeserializationContext ctxt) throws IOException { // 23-Mar-2017, tatu: Let's specifically block recursive resolution to avoid // either supporting nested arrays, or to cause infinite looping. if (p.hasToken(JsonToken.START_ARRAY)) { String msg = String.format( "Can not deserialize instance of %s out of %s token: nested Arrays not allowed with %s", ClassUtil.nameOf(_valueClass), JsonToken.START_ARRAY, "DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS"); @SuppressWarnings("unchecked") T result = (T) ctxt.handleUnexpectedToken(_valueClass, p.getCurrentToken(), p, msg); return result; } return (T) deserialize(p, ctxt); } /* /**************************************************** /* Helper methods for sub-classes, coercions /**************************************************** */ protected void _failDoubleToIntCoercion(JsonParser p, DeserializationContext ctxt, String type) throws IOException { ctxt.reportInputMismatch(handledType(), "Can not coerce a floating-point value ('%s') into %s (enable `DeserializationFeature.ACCEPT_FLOAT_AS_INT` to allow)", p.getValueAsString(), type); } /** * Helper method called in case where an integral number is encountered, but * config settings suggest that a coercion may be needed to "upgrade" * {@link java.lang.Number} into "bigger" type like {@link java.lang.Long} or * {@link java.math.BigInteger} * * @see DeserializationFeature#USE_BIG_INTEGER_FOR_INTS * @see DeserializationFeature#USE_LONG_FOR_INTS * * @since 2.6 */ protected Object _coerceIntegral(JsonParser p, DeserializationContext ctxt) throws IOException { int feats = ctxt.getDeserializationFeatures(); if (DeserializationFeature.USE_BIG_INTEGER_FOR_INTS.enabledIn(feats)) { return p.getBigInteger

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>Value(); } if (DeserializationFeature.USE_LONG_FOR_INTS.enabledIn(feats)) { return p.getLongValue(); } return p.getBigIntegerValue(); // should be optimal, whatever it is } /** * Method to call when JSON `null` token is encountered. Note: only called when * this deserializer encounters it but NOT when reached via property * * @since 2.9 */ protected Object _coerceNullToken(DeserializationContext ctxt, boolean isPrimitive) throws JsonMappingException { if (isPrimitive) { _verifyNullForPrimitive(ctxt); } return getNullValue(ctxt); } /** * Method called when JSON String with value "null" is encountered. * * @since 2.9 */ protected Object _coerceTextualNull(DeserializationContext ctxt, boolean isPrimitive) throws JsonMappingException { Enum<?> feat; boolean enable; if (!ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS)) { feat = MapperFeature.ALLOW_COERCION_OF_SCALARS; enable = true; } else if (isPrimitive && ctxt.isEnabled(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES)) { feat = DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES; enable = false; } else { return getNullValue(ctxt); } _reportFailedNullCoerce(ctxt, enable, feat, "String \"null\""); return null; } /** * Method called when JSON String with value "" (that is, zero length) is encountered. * * @since 2.9 */ protected Object _coerceEmptyString(DeserializationContext ctxt, boolean isPrimitive) throws JsonMappingException { Enum<?> feat; boolean enable; if (!ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS)) { feat = MapperFeature.ALLOW_COERCION_OF_SCALARS; enable = true; } else if (isPrimitive && ctxt.isEnabled(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES)) { feat = DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES; enable = false; }

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>.isAssignableFrom(cls); typeDesc = ClassUtil.nameOf(cls); } if (structured) { return String.format("as content of type `%s`", typeDesc); } return String.format("for type `%s`", typeDesc); } /* /**************************************************** /* Helper methods for sub-classes, resolving dependencies /**************************************************** */ /** * Helper method used to locate deserializers for properties the * type this deserializer handles contains (usually for properties of * bean types) * * @param type Type of property to deserialize * @param property Actual property object (field, method, constuctor parameter) used * for passing deserialized values; provided so deserializer can be contextualized if necessary */ protected JsonDeserializer<Object> findDeserializer(DeserializationContext ctxt, JavaType type, BeanProperty property) throws JsonMappingException { return ctxt.findContextualValueDeserializer(type, property); } /** * Helper method to check whether given text refers to what looks like a clean simple * integer number, consisting of optional sign followed by a sequence of digits. */ protected final boolean _isIntNumber(String text) { final int len = text.length(); if (len > 0) { char c = text.charAt(0); // skip leading sign (plus not allowed for strict JSON numbers but...) int i = (c == '-' || c == '+') ? 1 : 0; for (; i < len; ++i) { int ch = text.charAt(i); if (ch > '9' || ch < '0') { return false; } } return true; } return false; } /* /********************************************************** /* Helper methods for: deserializer construction /********************************************************** */ /** * Helper method that can be used to see if specified property has annotation * indicating that a converter is to be used for contained values (contents * of structured types; array/List/Map values) * * @param existingDeserializer (optional) configured content * serializer if one already exists. * * @since 2.2 */ protected JsonDeserializer<?> findConvertingContentDeserializer(DeserializationContext ctxt, BeanProperty prop, JsonDeserializer<?> existingDeserializer) throws

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>sig); } sb.append('>'); return sb.toString(); } @Override public int hashCode() { return _hashCode; } @Override public boolean equals(Object o) { if (o == this) return true; if (!ClassUtil.hasClass(o, getClass())) { return false; } TypeBindings other = (TypeBindings) o; int len = _types.length; if (len != other.size()) { return false; } JavaType[] otherTypes = other._types; for (int i = 0; i < len; ++i) { if (!otherTypes[i].equals(_types[i])) { return false; } } return true; } /* /********************************************************************** /* Package accessible methods /********************************************************************** */ protected JavaType[] typeParameterArray() { return _types; } /* /********************************************************************** /* Helper classes /********************************************************************** */ // 30-Oct-2015, tatu: Surprising, but looks like type parameters access can be bit of // a hot spot. So avoid for a small number of common generic types. Note that we do // need both common abstract types and concrete ones; latter for specialization /** * Helper class that contains simple logic for avoiding repeated lookups via * {@link Class#getTypeParameters()} as that can be a performance issue for * some use cases (wasteful, usually one-off or not reusing mapper). * Partly isolated to avoid initialization for cases where no generic types are * used. */ static class TypeParamStash { private final static TypeVariable<?>[] VARS_ABSTRACT_LIST = AbstractList.class.getTypeParameters(); private final static TypeVariable<?>[] VARS_COLLECTION = Collection.class.getTypeParameters(); private final static TypeVariable<?>[] VARS_ITERABLE = Iterable.class.getTypeParameters(); private final static TypeVariable<?>[] VARS_LIST = List.class.getTypeParameters(); private final static TypeVariable<?>[] VARS_ARRAY_LIST = ArrayList.class.getTypeParameters(); private final static TypeVariable<?>[] VARS_MAP = Map.class.getTypeParameters(); private final static TypeVariable<?>[] VARS_HASH_MAP =

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> * a {@link com.fasterxml.jackson.databind.node.NullNode} will be returned, * not null. * * @return Node that represent value of the specified element, * if this node is an array and has specified element. * Null otherwise. */ @Override public abstract JsonNode get(int index); /** * Method for accessing value of the specified field of * an object node. If this node is not an object (or it * does not have a value for specified field name), or * if there is no field with such name, null is returned. *<p> * NOTE: if the property value has been explicitly set as <code>null</code> * (which is different from removal!), * a {@link com.fasterxml.jackson.databind.node.NullNode} will be returned, * not null. * * @return Node that represent value of the specified field, * if this node is an object and has value for the specified * field. Null otherwise. */ @Override public JsonNode get(String fieldName) { return null; } /** * This method is similar to {@link #get(String)}, except * that instead of returning null if no such value exists (due * to this node not being an object, or object not having value * for the specified field), * a "missing node" (node that returns true for * {@link #isMissingNode}) will be returned. This allows for * convenient and safe chained access via path calls. */ @Override public abstract JsonNode path(String fieldName); /** * This method is similar to {@link #get(int)}, except * that instead of returning null if no such element exists (due * to index being out of range, or this node not being an array), * a "missing node" (node that returns true for * {@link #isMissingNode}) will be returned. This allows for * convenient and safe chained access via path calls. */ @Override public abstract JsonNode path(int index); @Override public Iterator<String> fieldNames() { return ClassUtil.emptyIterator(); } /** * Method for locating node specified by given JSON pointer instances. * Method will never return null; if no matching

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>pre> * node.get(index) != null &lt;&lt; !node.get(index).isNull() *</pre> * * @since 2.1 */ public boolean hasNonNull(int index) { JsonNode n = get(index); return (n != null) && !n.isNull(); } /* /********************************************************** /* Public API, container access /********************************************************** */ /** * Same as calling {@link #elements}; implemented so that * convenience "for-each" loop can be used for looping over elements * of JSON Array constructs. */ @Override public final Iterator<JsonNode> iterator() { return elements(); } /** * Method for accessing all value nodes of this Node, iff * this node is a JSON Array or Object node. In case of Object node, * field names (keys) are not included, only values. * For other types of nodes, returns empty iterator. */ public Iterator<JsonNode> elements() { return ClassUtil.emptyIterator(); } /** * @return Iterator that can be used to traverse all key/value pairs for * object nodes; empty iterator (no contents) for other types */ public Iterator<Map.Entry<String, JsonNode>> fields() { return ClassUtil.emptyIterator(); } /* /********************************************************** /* Public API, find methods /********************************************************** */ /** * Method for finding a JSON Object field with specified name in this * node or its child nodes, and returning value it has. * If no matching field is found in this node or its descendants, returns null. * * @param fieldName Name of field to look for * * @return Value of first matching node found, if any; null if none */ public abstract JsonNode findValue(String fieldName); /** * Method for finding JSON Object fields with specified name, and returning * found ones as a List. Note that sub-tree search ends if a field is found, * so possible children of result nodes are <b>not</b> included. * If no matching fields are found in this node or its descendants, returns * an empty List. * * @param fieldName Name of field to look for */ public final List<JsonNode> findValues(String

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> } /* 19-Feb-2010, tatus: Holy mackarel; primitive types * have 'abstract' flag set... */ return _class.isPrimitive(); } @Override public boolean isThrowable() { return Throwable.class.isAssignableFrom(_class); } @Override public boolean isArrayType() { return false; } @Override public final boolean isEnumType() { return _class.isEnum(); } @Override public final boolean isInterface() { return _class.isInterface(); } @Override public final boolean isPrimitive() { return _class.isPrimitive(); } @Override public final boolean isFinal() { return Modifier.isFinal(_class.getModifiers()); } /** * @return True if type represented is a container type; this includes * array, Map and Collection types. */ @Override public abstract boolean isContainerType(); /** * @return True if type is either true {@link java.util.Collection} type, * or something similar (meaning it has at least one type parameter, * which describes type of contents) */ @Override public boolean isCollectionLikeType() { return false; } /** * @return True if type is either true {@link java.util.Map} type, * or something similar (meaning it has at least two type parameter; * first one describing key type, second value type) */ @Override public boolean isMapLikeType() { return false; } /** * Convenience method, short-hand for *<code> * getRawClass() == Object.class *</code> * and used to figure if we basically have "untyped" type object. * * @since 2.5 */ public final boolean isJavaLangObject() { return _class == Object.class; } /** * Accessor for checking whether handlers for dealing with values of * this type should use static typing (as opposed to dynamic typing). * Note that while value of 'true' does mean that static typing is to * be used, value of 'false' may still be overridden by other settings. * * @since 2.2 */ public final boolean useStaticType() { return _asStatic;

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>Deserializer, nva); } @Override public void fixAccess(DeserializationConfig config) { if (_fallbackSetter != null) { _fallbackSetter.fixAccess(config); } } /** * NOTE: one exception to immutability, due to problems with CreatorProperty instances * being shared between Bean, separate PropertyBasedCreator * * @since 2.6 */ public void setFallbackSetter(SettableBeanProperty fallbackSetter) { _fallbackSetter = fallbackSetter; } /** * Method that can be called to locate value to be injected for this * property, if it is configured for this. */ public Object findInjectableValue(DeserializationContext context, Object beanInstance) throws JsonMappingException { if (_injectableValueId == null) { context.reportBadDefinition(ClassUtil.classOf(beanInstance), String.format("Property '%s' (type %s) has no injectable value id configured", getName(), getClass().getName())); } return context.findInjectableValue(_injectableValueId, this, beanInstance); } /** * Method to find value to inject, and inject it to this property. */ public void inject(DeserializationContext context, Object beanInstance) throws IOException { set(beanInstance, findInjectableValue(context, beanInstance)); } /* /********************************************************** /* BeanProperty impl /********************************************************** */ @Override public <A extends Annotation> A getAnnotation(Class<A> acls) { if (_annotated == null) { return null; } return _annotated.getAnnotation(acls); } @Override public AnnotatedMember getMember() { return _annotated; } @Override public int getCreatorIndex() { return _creatorIndex; } /* /********************************************************** /* Overridden methods /********************************************************** */ @Override public void deserializeAndSet(JsonParser p, DeserializationContext ctxt, Object instance) throws IOException { _verifySetter(); _fallbackSetter.set(instance, deserialize(p, ctxt)); } @Override public Object deserializeSetAndReturn(JsonParser p, DeserializationContext ctxt, Object instance) throws IOException { _verifySetter(); return _fallbackSetter.setAndReturn(instance, deserialize(

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>; } return getConfig().constructSpecializedType(baseType, subclass); } public abstract TypeFactory getTypeFactory(); /* /********************************************************** /* Helper object construction /********************************************************** */ public ObjectIdGenerator<?> objectIdGeneratorInstance(Annotated annotated, ObjectIdInfo objectIdInfo) throws JsonMappingException { Class<?> implClass = objectIdInfo.getGeneratorType(); final MapperConfig<?> config = getConfig(); HandlerInstantiator hi = config.getHandlerInstantiator(); ObjectIdGenerator<?> gen = (hi == null) ? null : hi.objectIdGeneratorInstance(config, annotated, implClass); if (gen == null) { gen = (ObjectIdGenerator<?>) ClassUtil.createInstance(implClass, config.canOverrideAccessModifiers()); } return gen.forScope(objectIdInfo.getScope()); } public ObjectIdResolver objectIdResolverInstance(Annotated annotated, ObjectIdInfo objectIdInfo) { Class<? extends ObjectIdResolver> implClass = objectIdInfo.getResolverType(); final MapperConfig<?> config = getConfig(); HandlerInstantiator hi = config.getHandlerInstantiator(); ObjectIdResolver resolver = (hi == null) ? null : hi.resolverIdGeneratorInstance(config, annotated, implClass); if (resolver == null) { resolver = ClassUtil.createInstance(implClass, config.canOverrideAccessModifiers()); } return resolver; } /** * Helper method to use to construct a {@link Converter}, given a definition * that may be either actual converter instance, or Class for instantiating one. * * @since 2.2 */ @SuppressWarnings("unchecked") public Converter<Object,Object> converterInstance(Annotated annotated, Object converterDef) throws JsonMappingException { if (converterDef == null) { return null; } if (converterDef instanceof Converter<?,?>) { return (Converter<Object,Object>) converterDef; } if (!(converterDef instanceof Class)) { throw new IllegalStateException("AnnotationIntrospector returned Converter definition of type " +converterDef.getClass().getName()+"; expected type Converter or Class<Converter> instead"); } Class<?> converterClass = (Class<?>)converterDef; // there are some known "no class" markers to consider too: if (converterClass == Converter.None.

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>class || ClassUtil.isBogusClass(converterClass)) { return null; } if (!Converter.class.isAssignableFrom(converterClass)) { throw new IllegalStateException("AnnotationIntrospector returned Class " +converterClass.getName()+"; expected Class<Converter>"); } final MapperConfig<?> config = getConfig(); HandlerInstantiator hi = config.getHandlerInstantiator(); Converter<?,?> conv = (hi == null) ? null : hi.converterInstance(config, annotated, converterClass); if (conv == null) { conv = (Converter<?,?>) ClassUtil.createInstance(converterClass, config.canOverrideAccessModifiers()); } return (Converter<Object,Object>) conv; } /* /********************************************************** /* Error reporting /********************************************************** */ /** * Helper method called to indicate a generic problem that stems from type * definition(s), not input data, or input/output state; typically this * means throwing a {@link com.fasterxml.jackson.databind.exc.InvalidDefinitionException}. * * @since 2.9 */ public abstract <T> T reportBadDefinition(JavaType type, String msg) throws JsonMappingException; /** * @since 2.9 */ public <T> T reportBadDefinition(Class<?> type, String msg) throws JsonMappingException { return reportBadDefinition(constructType(type), msg); } /* /********************************************************** /* Helper methods /********************************************************** */ /** * @since 2.9 */ protected final String _format(String msg, Object... msgArgs) { if (msgArgs.length > 0) { return String.format(msg, msgArgs); } return msg; } /** * @since 2.9 */ protected final String _truncate(String desc) { if (desc == null) { return ""; } if (desc.length() <= MAX_ERROR_STR_LEN) { return desc; } return desc.substring(0, MAX_ERROR_STR_LEN) + "]...[" + desc.substring(desc.length() - MAX_ERROR_STR_LEN); } /** * @since 2.9 */ protected String _quotedString(String desc)

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>ClassFor(_class); } } public static AnnotatedClass resolve(MapperConfig<?> config, JavaType forType, MixInResolver r) { return new AnnotatedClassResolver(config, forType, r).resolveFully(); } public static AnnotatedClass resolveWithoutSuperTypes(MapperConfig<?> config, JavaType forType, MixInResolver r) { return new AnnotatedClassResolver(config, forType, r).resolveWithoutSuperTypes(); } public static AnnotatedClass resolveWithoutSuperTypes(MapperConfig<?> config, Class<?> forType) { return resolveWithoutSuperTypes(config, forType, config); } public static AnnotatedClass resolveWithoutSuperTypes(MapperConfig<?> config, Class<?> forType, MixInResolver r) { return new AnnotatedClassResolver(config, forType, r).resolveWithoutSuperTypes(); } /** * Internal helper class used for resolving a small set of "primordial" types for which * we do not accept any annotation information or overrides. */ static AnnotatedClass createPrimordial(Class<?> raw) { Annotations noClassAnn = new AnnotationMap(); List<JavaType> superTypes = Collections.emptyList(); return new AnnotatedClass(null, raw, superTypes, null, noClassAnn, TypeBindings.emptyBindings(), null, null, null); } AnnotatedClass resolveFully() { List<JavaType> superTypes = ClassUtil.findSuperTypes(_type, null, false); Annotations classAnn = resolveClassAnnotations(superTypes); return new AnnotatedClass(_type, _class, superTypes, _primaryMixin, classAnn, _bindings, _intr, _mixInResolver, _config.getTypeFactory()); } AnnotatedClass resolveWithoutSuperTypes() { List<JavaType> superTypes = Collections.<JavaType>emptyList(); Annotations classAnn = resolveClassAnnotations(superTypes); return new AnnotatedClass(null, _class, superTypes, _primaryMixin, classAnn, _bindings, _intr, _config, _config.getTypeFactory()); } /* /********************************************************** /* Class annotation resolution /********************************************************** */ /** * Initialization method that will recursively collect Jackson * annotations for this class and all super classes and

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> * interfaces. */ private Annotations resolveClassAnnotations(List<JavaType> superTypes) { // Should skip processing if annotation processing disabled if (_intr == null) { return NO_ANNOTATIONS; } AnnotationCollector resolvedCA = AnnotationCollector.emptyCollector(); // add mix-in annotations first (overrides) if (_primaryMixin != null) { resolvedCA = _addClassMixIns(resolvedCA, _class, _primaryMixin); } // then annotations from the class itself: resolvedCA = _addAnnotationsIfNotPresent(resolvedCA, ClassUtil.findClassAnnotations(_class)); // and then from super types for (JavaType type : superTypes) { // and mix mix-in annotations in-between if (_mixInResolver != null) { Class<?> cls = type.getRawClass(); resolvedCA = _addClassMixIns(resolvedCA, cls, _mixInResolver.findMixInClassFor(cls)); } resolvedCA = _addAnnotationsIfNotPresent(resolvedCA, ClassUtil.findClassAnnotations(type.getRawClass())); } /* and finally... any annotations there might be for plain * old Object.class: separate because for all other purposes * it is just ignored (not included in super types) */ // 12-Jul-2009, tatu: Should this be done for interfaces too? // For now, yes, seems useful for some cases, and not harmful for any? if (_mixInResolver != null) { resolvedCA = _addClassMixIns(resolvedCA, Object.class, _mixInResolver.findMixInClassFor(Object.class)); } return resolvedCA.asAnnotations(); } private AnnotationCollector _addClassMixIns(AnnotationCollector annotations, Class<?> target, Class<?> mixin) { if (mixin != null) { // Ok, first: annotations from mix-in class itself: annotations = _addAnnotationsIfNotPresent(annotations, ClassUtil.findClassAnnotations(mixin)); // And then from its supertypes, if any. But note that we will only consider // super-types up until reaching the masked class (if found); this because // often mix-in class is a sub-class (for convenience reasons). // And if so,

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> we absolutely must NOT include super types of masked class, // as that would inverse precedence of annotations. for (Class<?> parent : ClassUtil.findSuperClasses(mixin, target, false)) { annotations = _addAnnotationsIfNotPresent(annotations, ClassUtil.findClassAnnotations(parent)); } } return annotations; } private AnnotationCollector _addAnnotationsIfNotPresent(AnnotationCollector c, Annotation[] anns) { if (anns != null) { for (Annotation ann : anns) { // first: direct annotations // note: we will NOT filter out non-Jackson annotations any more if (!c.isPresent(ann)) { c = c.addOrOverride(ann); if (_intr.isAnnotationBundle(ann)) { c = _addFromBundleIfNotPresent(c, ann); } } } } return c; } private AnnotationCollector _addFromBundleIfNotPresent(AnnotationCollector c, Annotation bundle) { for (Annotation ann : ClassUtil.findClassAnnotations(bundle.annotationType())) { // minor optimization: by-pass 2 common JDK meta-annotations if ((ann instanceof Target) || (ann instanceof Retention)) { continue; } if (!c.isPresent(ann)) { c = c.addOrOverride(ann); if (_intr.isAnnotationBundle(ann)) { c = _addFromBundleIfNotPresent(c, ann); } } } return c; } }

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>; // contextualization will only occur at a later point return ctxt.findNonContextualValueDeserializer(type); } protected JsonDeserializer<Object> _clearIfStdImpl(JsonDeserializer<Object> deser) { return ClassUtil.isJacksonStdImpl(deser) ? null : deser; } /** * We only use contextualization for optimizing the case where no customization * occurred; if so, can slip in a more streamlined version. */ @Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { // 20-Apr-2014, tatu: If nothing custom, let's use "vanilla" instance, // simpler and can avoid some of delegation if ((_stringDeserializer == null) && (_numberDeserializer == null) && (_mapDeserializer == null) && (_listDeserializer == null) && getClass() == UntypedObjectDeserializer.class) { return Vanilla.std; } return this; } /* /********************************************************** /* Deserializer API /********************************************************** */ /* 07-Nov-2014, tatu: When investigating [databind#604], realized that it makes * sense to also mark this is cachable, since lookup not exactly free, and * since it's not uncommon to "read anything" */ @Override public boolean isCachable() { /* 26-Mar-2015, tatu: With respect to [databind#735], there are concerns over * cachability. It seems like we SHOULD be safe here; but just in case there * are problems with false sharing, this may need to be revisited. */ return true; } @Override // since 2.9 public Boolean supportsUpdate(DeserializationConfig config) { // 21-Apr-2017, tatu: Bit tricky... some values, yes. So let's say "dunno" return null; } @Override public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { switch (p.getCurrentTokenId()) { case JsonTokenId.ID_START_OBJECT: case

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>._annotated; _field = src._field; _skipNulls = src._skipNulls; } /** * Constructor used for JDK Serialization when reading persisted object */ protected FieldProperty(FieldProperty src) { super(src); _annotated = src._annotated; Field f = _annotated.getAnnotated(); if (f == null) { throw new IllegalArgumentException("Missing field (broken JDK (de)serialization?)"); } _field = f; _skipNulls = src._skipNulls; } @Override public SettableBeanProperty withName(PropertyName newName) { return new FieldProperty(this, newName); } @Override public SettableBeanProperty withValueDeserializer(JsonDeserializer<?> deser) { if (_valueDeserializer == deser) { return this; } return new FieldProperty(this, deser, _nullProvider); } @Override public SettableBeanProperty withNullProvider(NullValueProvider nva) { return new FieldProperty(this, _valueDeserializer, nva); } @Override public void fixAccess(DeserializationConfig config) { ClassUtil.checkAndFixAccess(_field, config.isEnabled(MapperFeature.OVERRIDE_PUBLIC_ACCESS_MODIFIERS)); } /* /********************************************************** /* BeanProperty impl /********************************************************** */ @Override public <A extends Annotation> A getAnnotation(Class<A> acls) { return (_annotated == null) ? null : _annotated.getAnnotation(acls); } @Override public AnnotatedMember getMember() { return _annotated; } /* /********************************************************** /* Overridden methods /********************************************************** */ @Override public void deserializeAndSet(JsonParser p, DeserializationContext ctxt, Object instance) throws IOException { Object value; if (p.hasToken(JsonToken.VALUE_NULL)) { if (_skipNulls) { return; } value = _nullProvider.getNullValue(ctxt); } else if (_valueTypeDeserializer == null) { value = _valueDeserializer.deserialize(p, ctxt); } else { value = _valueDeserializer.deserializeWithType(p, ctxt, _valueTypeDeserializer); } try { _field.set(instance, value); } catch (Exception

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>package com.fasterxml.jackson.databind.ext; import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.PropertyName; import com.fasterxml.jackson.databind.introspect.Annotated; import com.fasterxml.jackson.databind.introspect.AnnotatedParameter; import com.fasterxml.jackson.databind.util.ClassUtil; /** * To support Java7-incomplete platforms, we will offer support for JDK 7 * annotations through this class, loaded dynamically; if loading fails, * support will be missing. This class is the non-JDK-7-dependent API, * and {@link Java7SupportImpl} is JDK7-dependent implementation of * functionality. */ public abstract class Java7Support { private final static Java7Support IMPL; static { Java7Support impl = null; try { Class<?> cls = Class.forName("com.fasterxml.jackson.databind.ext.Java7SupportImpl"); impl = (Java7Support) ClassUtil.createInstance(cls, false); } catch (Throwable t) { // 24-Nov-2015, tatu: Should we log or not? java.util.logging.Logger.getLogger(Java7Support.class.getName()) .warning("Unable to load JDK7 types (annotations, java.nio.file.Path): no Java7 support added"); } IMPL = impl; } public static Java7Support instance() { return IMPL; } public abstract Boolean findTransient(Annotated a); public abstract Boolean hasCreatorAnnotation(Annotated a); public abstract PropertyName findConstructorName(AnnotatedParameter p); public abstract Class<?> getClassJavaNioFilePath(); public abstract JsonDeserializer<?> getDeserializerForJavaNioFilePath(Class<?> rawType); public abstract JsonSerializer<?> getSerializerForJavaNioFilePath(Class<?> rawType); }

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> and deserializers will also ignore any * attempts to enforce typing. */ public boolean useForType(JavaType t) { // 03-Oct-2016, tatu: As per [databind#1395], need to skip // primitive types too, regardless if (t.isPrimitive()) { return false; } switch (_appliesFor) { case NON_CONCRETE_AND_ARRAYS: while (t.isArrayType()) { t = t.getContentType(); } // fall through case OBJECT_AND_NON_CONCRETE: // 19-Apr-2016, tatu: ReferenceType like Optional also requires similar handling: while (t.isReferenceType()) { t = t.getReferencedType(); } return t.isJavaLangObject() || (!t.isConcrete() // [databind#88] Should not apply to JSON tree models: && !TreeNode.class.isAssignableFrom(t.getRawClass())); case NON_FINAL: while (t.isArrayType()) { t = t.getContentType(); } // 19-Apr-2016, tatu: ReferenceType like Optional also requires similar handling: while (t.isReferenceType()) { t = t.getReferencedType(); } // [databind#88] Should not apply to JSON tree models: return !t.isFinal() && !TreeNode.class.isAssignableFrom(t.getRawClass()); default: //case JAVA_LANG_OBJECT: return t.isJavaLangObject(); } } } /* /********************************************************** /* Internal constants, singletons /********************************************************** */ // Quick little shortcut, to avoid having to use global TypeFactory instance... // 19-Oct-2015, tatu: Not sure if this is really safe to do; let's at least allow // some amount of introspection private final static JavaType JSON_NODE_TYPE = SimpleType.constructUnsafe(JsonNode.class); // TypeFactory.defaultInstance().constructType(JsonNode.class); // 16-May-2009, tatu: Ditto ^^^ protected final static AnnotationIntrospector DEFAULT_AN

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>********************************************************** /* Internal methods for serialization, overridable /********************************************************** */ /** * Overridable helper method used for constructing * {@link SerializerProvider} to use for serialization. */ protected DefaultSerializerProvider _serializerProvider(SerializationConfig config) { return _serializerProvider.createInstance(config, _serializerFactory); } /** * Method called to configure the generator as necessary and then * call write functionality */ protected final void _configAndWriteValue(JsonGenerator g, Object value) throws IOException { SerializationConfig cfg = getSerializationConfig(); cfg.initialize(g); // since 2.5 if (cfg.isEnabled(SerializationFeature.CLOSE_CLOSEABLE) && (value instanceof Closeable)) { _configAndWriteCloseable(g, value, cfg); return; } try { _serializerProvider(cfg).serializeValue(g, value); } catch (Exception e) { ClassUtil.closeOnFailAndThrowAsIAE(g, e); return; } g.close(); } /** * Helper method used when value to serialize is {@link Closeable} and its <code>close()</code> * method is to be called right after serialization has been called */ private final void _configAndWriteCloseable(JsonGenerator g, Object value, SerializationConfig cfg) throws IOException { Closeable toClose = (Closeable) value; try { _serializerProvider(cfg).serializeValue(g, value); Closeable tmpToClose = toClose; toClose = null; tmpToClose.close(); } catch (Exception e) { ClassUtil.closeOnFailAndThrowAsIAE(g, toClose, e); return; } g.close(); } /** * Helper method used when value to serialize is {@link Closeable} and its <code>close()</code> * method is to be called right after serialization has been called */ private final void _writeCloseableValue(JsonGenerator g, Object value, SerializationConfig cfg) throws IOException { Closeable toClose = (Closeable) value; try { _serializerProvider(cfg).serializeValue(g, value); if (cfg.isEnabled(SerializationFeature.FLUSH_AFTER_WRITE_VALUE)) { g.

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>flush(); } } catch (Exception e) { ClassUtil.closeOnFailAndThrowAsIAE(null, toClose, e); return; } toClose.close(); } /* /********************************************************** /* Internal methods for deserialization, overridable /********************************************************** */ /** * Internal helper method called to create an instance of {@link DeserializationContext} * for deserializing a single root value. * Can be overridden if a custom context is needed. */ protected DefaultDeserializationContext createDeserializationContext(JsonParser p, DeserializationConfig cfg) { return _deserializationContext.createInstance(cfg, p, _injectableValues); } /** * Actual implementation of value reading+binding operation. */ protected Object _readValue(DeserializationConfig cfg, JsonParser p, JavaType valueType) throws IOException { /* First: may need to read the next token, to initialize * state (either before first read from parser, or after * previous token has been cleared) */ Object result; JsonToken t = _initForReading(p, valueType); if (t == JsonToken.VALUE_NULL) { // Ask JsonDeserializer what 'null value' to use: DeserializationContext ctxt = createDeserializationContext(p, cfg); result = _findRootDeserializer(ctxt, valueType).getNullValue(ctxt); } else if (t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = null; } else { // pointing to event other than null DeserializationContext ctxt = createDeserializationContext(p, cfg); JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, valueType); // ok, let's get the value if (cfg.useRootWrapping()) { result = _unwrapAndDeserialize(p, ctxt, cfg, valueType, deser); } else { result = deser.deserialize(p, ctxt); } } // Need to consume the token too p.clearCurrentToken(); return result; } protected Object _readMapAndClose(JsonParser p0, JavaType valueType) throws IOException { try (JsonParser p = p0) { Object result; JsonToken t = _initForReading(p, value

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>ClassFor(Object.class); if (mixin != null) { _addMethodMixIns(tc, mainType.getRawClass(), memberMethods, mixin, mixins); } } // Any unmatched mix-ins? Most likely error cases (not matching any method); // but there is one possible real use case: exposing Object#hashCode // (alas, Object#getClass can NOT be exposed) if (_intr != null) { if (!mixins.isEmpty()) { Iterator<AnnotatedMethod> it = mixins.iterator(); while (it.hasNext()) { AnnotatedMethod mixIn = it.next(); try { Method m = Object.class.getDeclaredMethod(mixIn.getName(), mixIn.getRawParameterTypes()); if (m != null) { // Since it's from java.lang.Object, no generics, no need for real type context: AnnotatedMethod am = _constructMethod(tc, m); _addMixOvers(mixIn.getAnnotated(), am, false); memberMethods.add(am); } } catch (Exception e) { } } } } */ // And then let's if (methods.isEmpty()) { return new AnnotatedMethodMap(); } Map<MemberKey,AnnotatedMethod> actual = new LinkedHashMap<>(methods.size()); for (Map.Entry<MemberKey,MethodBuilder> entry : methods.entrySet()) { AnnotatedMethod am = entry.getValue().build(); if (am != null) { actual.put(entry.getKey(), am); } } return new AnnotatedMethodMap(actual); } private void _addMemberMethods(TypeResolutionContext tc, Class<?> cls, Map<MemberKey,MethodBuilder> methods, Class<?> mixInCls) { // first, mixIns, since they have higher priority then class methods if (mixInCls != null) { _addMethodMixIns(tc, cls, methods, mixInCls); } if (cls == null) { // just so caller need not check when passing super-class return; } // then methods from the class itself for (Method m : ClassUtil.getClassMethods(cls)) { if (!_isIncludableMemberMethod(m)) { continue; } final Member

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>Key key = new MemberKey(m); MethodBuilder b = methods.get(key); if (b == null) { AnnotationCollector c = (_intr == null) ? AnnotationCollector.emptyCollector() : collectAnnotations(m.getDeclaredAnnotations()); methods.put(key, new MethodBuilder(tc, m, c)); } else { if (_intr != null) { b.annotations = collectDefaultAnnotations(b.annotations, m.getDeclaredAnnotations()); } Method old = b.method; if (old == null) { // had "mix-over", replace b.method = m; // } else if (old.getDeclaringClass().isInterface() && !m.getDeclaringClass().isInterface()) { } else if (Modifier.isAbstract(old.getModifiers()) && !Modifier.isAbstract(m.getModifiers())) { // 06-Jan-2010, tatu: Except that if method we saw first is // from an interface, and we now find a non-interface definition, we should // use this method, but with combination of annotations. // This helps (or rather, is essential) with JAXB annotations and // may also result in faster method calls (interface calls are slightly // costlier than regular method calls) b.method = m; } } } } protected void _addMethodMixIns(TypeResolutionContext tc, Class<?> targetClass, Map<MemberKey,MethodBuilder> methods, Class<?> mixInCls) { if (_intr == null) { return; } for (Class<?> mixin : ClassUtil.findRawSuperTypes(mixInCls, targetClass, true)) { for (Method m : ClassUtil.getDeclaredMethods(mixin)) { if (!_isIncludableMemberMethod(m)) { continue; } final MemberKey key = new MemberKey(m); MethodBuilder b = methods.get(key); Annotation[] anns = m.getDeclaredAnnotations(); if (b == null) { // nothing yet; add but do NOT specify method -- this marks it // as "mix-over", floating mix-in methods.put(key, new MethodBuilder(tc, null, collectAnnotations(anns))); } else {

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> */ /** * Method for getting current {@link DeserializerFactory}. */ public DeserializerFactory getFactory() { return _factory; } /** * Convenience method for checking whether specified on/off * feature is enabled */ public final boolean isEnabled(DeserializationFeature feat) { /* 03-Dec-2010, tatu: minor shortcut; since this is called quite often, * let's use a local copy of feature settings: */ return (_featureFlags & feat.getMask()) != 0; } /** * Bulk access method for getting the bit mask of all {@link DeserializationFeature}s * that are enabled. * * @since 2.6 */ public final int getDeserializationFeatures() { return _featureFlags; } /** * Bulk access method for checking that all features specified by * mask are enabled. * * @since 2.3 */ public final boolean hasDeserializationFeatures(int featureMask) { return (_featureFlags & featureMask) == featureMask; } /** * Bulk access method for checking that at least one of features specified by * mask is enabled. * * @since 2.6 */ public final boolean hasSomeOfFeatures(int featureMask) { return (_featureFlags & featureMask) != 0; } /** * Method for accessing the currently active parser. * May be different from the outermost parser * when content is buffered. *<p> * Use of this method is discouraged: if code has direct access * to the active parser, that should be used instead. */ public final JsonParser getParser() { return _parser; } public final Object findInjectableValue(Object valueId, BeanProperty forProperty, Object beanInstance) throws JsonMappingException { if (_injectableValues == null) { reportBadDefinition(ClassUtil.classOf(valueId), String.format( "No 'injectableValues' configured, can not inject value with id [%s]", valueId)); } return _injectableValues.findInjectableValue(valueId, this, forProperty, beanInstance); } /** * Convenience method for accessing the default Base64 encoding * used for decoding base6

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS><T> type) throws IOException { return readValue(p, getTypeFactory().constructType(type)); } /** * @since 2.4 */ @SuppressWarnings("unchecked") public <T> T readValue(JsonParser p, JavaType type) throws IOException { JsonDeserializer<Object> deser = findRootValueDeserializer(type); if (deser == null) { reportBadDefinition(type, "Could not find JsonDeserializer for type "+type); } return (T) deser.deserialize(p, this); } /** * Convenience method that may be used by composite or container deserializers, * for reading one-off values for the composite type, taking into account * annotations that the property (passed to this method -- usually property that * has custom serializer that called this method) has. * * @since 2.4 */ public <T> T readPropertyValue(JsonParser p, BeanProperty prop, Class<T> type) throws IOException { return readPropertyValue(p, prop, getTypeFactory().constructType(type)); } /** * @since 2.4 */ @SuppressWarnings("unchecked") public <T> T readPropertyValue(JsonParser p, BeanProperty prop, JavaType type) throws IOException { JsonDeserializer<Object> deser = findContextualValueDeserializer(type, prop); if (deser == null) { return reportBadDefinition(type, String.format( "Could not find JsonDeserializer for type %s (via property %s)", type, ClassUtil.nameOf(prop))); } return (T) deser.deserialize(p, this); } /* /********************************************************** /* Methods for problem handling /********************************************************** */ /** * Method that deserializers should call if they encounter an unrecognized * property (and once that is not explicitly designed as ignorable), to * inform possibly configured {@link DeserializationProblemHandler}s and * let it handle the problem. * * @return True if there was a configured problem handler that was able to handle the * problem */ public boolean handleUnknownProperty(JsonParser p, JsonDeserializer<?> deser, Object instanceOrClass, String propName) throws IOException { LinkedNode<DeserializationProblemHandler> h = _config.get

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> Method should be called at point where value * has not been decoded, so that handler has a chance to handle decoding * using alternate mechanism, and handle underlying content (possibly by * just skipping it) to keep input state valid * * @param instClass Type that was to be instantiated * @param valueInst (optional) Value instantiator to be used, if any; null if type does not * use one for instantiation (custom deserialiers don't; standard POJO deserializer does) * @param p Parser that points to the JSON value to decode * * @return Object that should be constructed, if any; has to be of type <code>instClass</code> * * @since 2.9 (2.8 had alternate that did not take <code>ValueInstantiator</code>) */ @SuppressWarnings("resource") public Object handleMissingInstantiator(Class<?> instClass, ValueInstantiator valueInst, JsonParser p, String msg, Object... msgArgs) throws IOException { if (p == null) { p = getParser(); } msg = _format(msg, msgArgs); LinkedNode<DeserializationProblemHandler> h = _config.getProblemHandlers(); while (h != null) { // Can bail out if it's handled Object instance = h.value().handleMissingInstantiator(this, instClass, valueInst, p, msg); if (instance != DeserializationProblemHandler.NOT_HANDLED) { // Sanity check for broken handlers, otherwise nasty to debug: if ((instance == null) || instClass.isInstance(instance)) { return instance; } reportBadDefinition(constructType(instClass), String.format( "DeserializationProblemHandler.handleMissingInstantiator() for type %s returned value of type %s", instClass, ClassUtil.classNameOf(instance))); } h = h.next(); } // 16-Oct-2016, tatu: This is either a definition problem (if no applicable creator // exists), or input mismatch problem (otherwise) since none of existing creators // match with token. if ((valueInst != null) && !valueInst.canInstantiate()) { msg = String.format("Can not construct instance of %s

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> (no Creators, like default construct, exist): %s", ClassUtil.nameOf(instClass), msg); return reportBadDefinition(constructType(instClass), msg); } msg = String.format("Can not construct instance of %s (although at least one Creator exists): %s", ClassUtil.nameOf(instClass), msg); return reportInputMismatch(instClass, msg); } /** * Method that deserializers should call if they fail to instantiate value * due to an exception that was thrown by constructor (or other mechanism used * to create instances). * Default implementation will try to call {@link DeserializationProblemHandler#handleInstantiationProblem} * on configured handlers, if any, to allow for recovery; if recovery does not * succeed, will throw exception constructed with {@link #instantiationException}. * * @param instClass Type that was to be instantiated * @param argument (optional) Argument that was passed to constructor or equivalent * instantiator; often a {@link java.lang.String}. * @param t Exception that caused failure * * @return Object that should be constructed, if any; has to be of type <code>instClass</code> * * @since 2.8 */ public Object handleInstantiationProblem(Class<?> instClass, Object argument, Throwable t) throws IOException { LinkedNode<DeserializationProblemHandler> h = _config.getProblemHandlers(); while (h != null) { // Can bail out if it's handled Object instance = h.value().handleInstantiationProblem(this, instClass, argument, t); if (instance != DeserializationProblemHandler.NOT_HANDLED) { // Sanity check for broken handlers, otherwise nasty to debug: if (instClass.isInstance(instance)) { return instance; } reportBadDefinition(constructType(instClass), String.format( "DeserializationProblemHandler.handleInstantiationProblem() for type %s returned value of type %s", instClass, ClassUtil.classNameOf(instance))); } h = h.next(); } // 18-May-2016, tatu: Only wrap if not already a valid type to throw ClassUtil.throwIfIOE(t); throw instantiationException(

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> * * @since 2.9 */ public void reportWrongTokenException(JsonDeserializer<?> deser, JsonToken expToken, String msg, Object... msgArgs) throws JsonMappingException { msg = _format(msg, msgArgs); throw wrongTokenException(getParser(), deser.handledType(), expToken, msg); } /** * Method for deserializers to call * when the token encountered was of type different than what <b>should</b> * be seen at that position, usually within a sequence of expected tokens. * Note that this method will throw a {@link JsonMappingException} and no * recovery is attempted (via {@link DeserializationProblemHandler}, as * problem is considered to be difficult to recover from, in general. * * @since 2.9 */ public void reportWrongTokenException(JavaType targetType, JsonToken expToken, String msg, Object... msgArgs) throws JsonMappingException { msg = _format(msg, msgArgs); throw wrongTokenException(getParser(), targetType, expToken, msg); } /** * Method for deserializers to call * when the token encountered was of type different than what <b>should</b> * be seen at that position, usually within a sequence of expected tokens. * Note that this method will throw a {@link JsonMappingException} and no * recovery is attempted (via {@link DeserializationProblemHandler}, as * problem is considered to be difficult to recover from, in general. * * @since 2.9 */ public void reportWrongTokenException(Class<?> targetType, JsonToken expToken, String msg, Object... msgArgs) throws JsonMappingException { msg = _format(msg, msgArgs); throw wrongTokenException(getParser(), targetType, expToken, msg); } /** * @since 2.8 */ public <T> T reportUnresolvedObjectId(ObjectIdReader oidReader, Object bean) throws JsonMappingException { String msg = String.format("No Object Id found for an instance of %s, to assign to property '%s'", ClassUtil.classNameOf(bean), oidReader.propertyName); return reportInputMismatch(oidReader.idProperty, msg); }

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> /** * Helper method for reporting a problem with unhandled unknown property. * * @param instanceOrClass Either value being populated (if one has been * instantiated), or Class that indicates type that would be (or * have been) instantiated * @param deser Deserializer that had the problem, if called by deserializer * (or on behalf of one) * * @deprecated Since 2.8 call {@link #handleUnknownProperty} instead */ @Deprecated public void reportUnknownProperty(Object instanceOrClass, String fieldName, JsonDeserializer<?> deser) throws JsonMappingException { if (isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)) { // Do we know properties that are expected instead? Collection<Object> propIds = (deser == null) ? null : deser.getKnownPropertyNames(); throw UnrecognizedPropertyException.from(_parser, instanceOrClass, fieldName, propIds); } } /** * @since 2.8 * * @deprecated Since 2.9: not clear this ever occurs */ @Deprecated // since 2.9 public void reportMissingContent(String msg, Object... msgArgs) throws JsonMappingException { throw MismatchedInputException.from(getParser(), (JavaType) null, "No content to map due to end-of-input"); } /* /********************************************************** /* Methods for problem reporting, in cases where recovery /* is not considered possible: POJO definition problems /********************************************************** */ /** * Helper method called to indicate problem in POJO (serialization) definitions or settings * regarding specific Java type, unrelated to actual JSON content to map. * Default behavior is to construct and throw a {@link JsonMappingException}. * * @since 2.9 */ public <T> T reportBadTypeDefinition(BeanDescription bean, String msg, Object... msgArgs) throws JsonMappingException { msg = _format(msg, msgArgs); String beanDesc = ClassUtil.nameOf(bean.getBeanClass()); msg = String.format("Invalid type definition for type %s: %s", beanDesc, msg); throw InvalidDefinitionException.from(_parser, msg, bean, null); } /** * Helper method called to indicate problem in POJO (

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>serialization) definitions or settings * regarding specific property (of a type), unrelated to actual JSON content to map. * Default behavior is to construct and throw a {@link JsonMappingException}. * * @since 2.9 */ public <T> T reportBadPropertyDefinition(BeanDescription bean, BeanPropertyDefinition prop, String msg, Object... msgArgs) throws JsonMappingException { msg = _format(msg, msgArgs); String propName = ClassUtil.nameOf(prop); String beanDesc = ClassUtil.nameOf(bean.getBeanClass()); msg = String.format("Invalid definition for property %s (of type %s): %s", propName, beanDesc, msg); throw InvalidDefinitionException.from(_parser, msg, bean, prop); } @Override public <T> T reportBadDefinition(JavaType type, String msg) throws JsonMappingException { throw InvalidDefinitionException.from(_parser, msg, type); } /** * Method that deserializer may call if it is called to do an update ("merge") * but deserializer operates on a non-mergeable type. Although this should * usually be caught earlier, sometimes it may only be caught during operation * and if so this is the method to call. * Note that if {@link MapperFeature#IGNORE_MERGE_FOR_UNMERGEABLE} is enabled, * this method will simply return null; otherwise {@link InvalidDefinitionException} * will be thrown. * * @since 2.9 */ public <T> T reportBadMerge(JsonDeserializer<?> deser) throws JsonMappingException { if (isEnabled(MapperFeature.IGNORE_MERGE_FOR_UNMERGEABLE)) { return null; } JavaType type = constructType(deser.handledType()); String msg = String.format("Invalid configuration: values of type %s can not be merged", type); throw InvalidDefinitionException.from(getParser(), msg, type); } /* /********************************************************** /* Methods for constructing semantic exceptions; usually not /* to be called directly, call `handleXxx()` instead /********************************************************** */ /** * Helper method for constructing {@link JsonMappingException} to indicate * that the token encountered was of type different than what <b>should</b>

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> * be seen at that position, usually within a sequence of expected tokens. * Note that most of the time this method should NOT be directly called; * instead, {@link #reportWrongTokenException} should be called and will * call this method as necessary. * * @since 2.9 */ public JsonMappingException wrongTokenException(JsonParser p, JavaType targetType, JsonToken expToken, String extra) { String msg = String.format("Unexpected token (%s), expected %s", p.getCurrentToken(), expToken); msg = _colonConcat(msg, extra); return MismatchedInputException.from(p, targetType, msg); } public JsonMappingException wrongTokenException(JsonParser p, Class<?> targetType, JsonToken expToken, String extra) { String msg = String.format("Unexpected token (%s), expected %s", p.getCurrentToken(), expToken); msg = _colonConcat(msg, extra); return MismatchedInputException.from(p, targetType, msg); } @Deprecated // since 2.9 public JsonMappingException wrongTokenException(JsonParser p, JsonToken expToken, String msg) { return wrongTokenException(p, (JavaType) null, expToken, msg); } /** * Helper method for constructing exception to indicate that given JSON * Object field name was not in format to be able to deserialize specified * key type. * Note that most of the time this method should NOT be called; instead, * {@link #handleWeirdKey} should be called which will call this method * if necessary. */ public JsonMappingException weirdKeyException(Class<?> keyClass, String keyValue, String msg) { return InvalidFormatException.from(_parser, String.format("Can not deserialize Map key of type %s from String %s: %s", ClassUtil.nameOf(keyClass), _quotedString(keyValue), msg), keyValue, keyClass); } /** * Helper method for constructing exception to indicate that input JSON * String was not suitable for deserializing into given target type. * Note that most of the time this method should NOT be called; instead, * {@link #handleWeirdStringValue} should be called which will

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> call this method * if necessary. * * @param value String value from input being deserialized * @param instClass Type that String should be deserialized into * @param msg Message that describes specific problem * * @since 2.1 */ public JsonMappingException weirdStringException(String value, Class<?> instClass, String msg) { return InvalidFormatException.from(_parser, String.format("Can not deserialize value of type %s from String %s: %s", ClassUtil.nameOf(instClass), _quotedString(value), msg), value, instClass); } /** * Helper method for constructing exception to indicate that input JSON * Number was not suitable for deserializing into given target type. * Note that most of the time this method should NOT be called; instead, * {@link #handleWeirdNumberValue} should be called which will call this method * if necessary. */ public JsonMappingException weirdNumberException(Number value, Class<?> instClass, String msg) { return InvalidFormatException.from(_parser, String.format("Can not deserialize value of type %s from number %s: %s", ClassUtil.nameOf(instClass), String.valueOf(value), msg), value, instClass); } /** * Helper method for constructing instantiation exception for specified type, * to indicate problem with physically constructing instance of * specified class (missing constructor, exception from constructor) *<p> * Note that most of the time this method should NOT be called; instead, * {@link #handleInstantiationProblem} should be called which will call this method * if necessary. */ public JsonMappingException instantiationException(Class<?> instClass, Throwable cause) { // Most likely problem with Creator definition, right? JavaType type = constructType(instClass); String msg = String.format("Can not construct instance of %s, problem: %s", ClassUtil.nameOf(instClass), cause.getMessage()); InvalidDefinitionException e = InvalidDefinitionException.from(_parser, msg, type); e.initCause(cause); return e; } /** * Helper method for constructing instantiation exception for specified type, * to indicate that instantiation failed due to missing instantiator * (creator; constructor or factory method).

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> *<p> * Note that most of the time this method should NOT be called; instead, * {@link #handleMissingInstantiator} should be called which will call this method * if necessary. */ public JsonMappingException instantiationException(Class<?> instClass, String msg0) { // Most likely problem with Creator definition, right? JavaType type = constructType(instClass); String msg = String.format("Can not construct instance of %s: %s", ClassUtil.nameOf(instClass), msg0); return InvalidDefinitionException.from(_parser, msg, type); } /** * Helper method for constructing exception to indicate that given type id * could not be resolved to a valid subtype of specified base type, during * polymorphic deserialization. *<p> * Note that most of the time this method should NOT be called; instead, * {@link #handleUnknownTypeId} should be called which will call this method * if necessary. */ public JsonMappingException unknownTypeIdException(JavaType baseType, String typeId, String extraDesc) { String msg = String.format("Could not resolve type id '%s' into a subtype of %s", typeId, baseType); return InvalidTypeIdException.from(_parser, _colonConcat(msg, extraDesc), baseType, typeId); } /** * @since 2.9 */ public JsonMappingException missingTypeIdException(JavaType baseType, String extraDesc) { String msg = String.format("Missing type id when trying to resolve subtype of %s", baseType); return InvalidTypeIdException.from(_parser, _colonConcat(msg, extraDesc), baseType, null); } /* /********************************************************** /* Deprecated exception factory methods /********************************************************** */ /** * @since 2.5 * * @deprecated Since 2.8 use {@link #handleUnknownTypeId} instead */ @Deprecated public JsonMappingException unknownTypeException(JavaType type, String id, String extraDesc) { String msg = String.format("Could not resolve type id '%s' into a subtype of %s", id, type); msg = _colonConcat(msg, extraDesc); return MismatchedInputException.from(_parser, type

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>", ClassUtil.classNameOf(_serializer), ClassUtil.classNameOf(ser))); } _serializer = ser; } /** * Method called to assign null value serializer for property */ public void assignNullSerializer(JsonSerializer<Object> nullSer) { // may need to disable check in future? if ((_nullSerializer != null) && (_nullSerializer != nullSer)) { throw new IllegalStateException(String.format( "Can not override _nullSerializer: had a %s, trying to set to %s", ClassUtil.classNameOf(_nullSerializer), ClassUtil.classNameOf(nullSer))); } _nullSerializer = nullSer; } /** * Method called create an instance that handles details of unwrapping * contained value. */ public BeanPropertyWriter unwrappingWriter(NameTransformer unwrapper) { return new UnwrappingBeanPropertyWriter(this, unwrapper); } /** * Method called to define type to consider as "non-trivial" basetype, * needed for dynamic serialization resolution for complex (usually * container) types */ public void setNonTrivialBaseType(JavaType t) { _nonTrivialBaseType = t; } /** * Method called to ensure that the mutator has proper access rights to * be called, as per configuration. Overridden by implementations that * have mutators that require access, fields and setters. * * @since 2.8.3 */ public void fixAccess(SerializationConfig config) { _member.fixAccess(config.isEnabled(MapperFeature.OVERRIDE_PUBLIC_ACCESS_MODIFIERS)); } /* /*********************************************************** /* JDK Serializability /*********************************************************** */ /* * Ideally would not require mutable state, and instead would re-create with * final settings. However, as things are, with sub-types and all, simplest * to just change Field/Method value directly. */ Object readResolve() { if (_member instanceof AnnotatedField) { _accessorMethod = null; _field = (Field) _member.getMember(); } else if (_member instanceof AnnotatedMethod) { _accessorMethod = (Method) _member.getMember(); _field = null; } if (_serializer == null) { _dynamic

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>package com.fasterxml.jackson.databind.deser.std; import java.io.IOException; import java.math.BigDecimal; import java.math.BigInteger; import java.util.HashSet; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.core.io.NumberInput; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; import com.fasterxml.jackson.databind.jsontype.TypeDeserializer; import com.fasterxml.jackson.databind.util.AccessPattern; /** * Container class for deserializers that handle core JDK primitive * (and matching wrapper) types, as well as standard "big" numeric types. * Note that this includes types such as {@link java.lang.Boolean} * and {@link java.lang.Character} which are not strictly numeric, * but are part of primitive/wrapper types. */ public class NumberDeserializers { private final static HashSet<String> _classNames = new HashSet<String>(); static { // note: can skip primitive types; other ways to check them: Class<?>[] numberTypes = new Class<?>[] { Boolean.class, Byte.class, Short.class, Character.class, Integer.class, Long.class, Float.class, Double.class, // and more generic ones Number.class, BigDecimal.class, BigInteger.class }; for (Class<?> cls : numberTypes) { _classNames.add(cls.getName()); } } public static JsonDeserializer<?> find(Class<?> rawType, String clsName) { if (rawType.isPrimitive()) { if (rawType == Integer.TYPE) { return IntegerDeserializer.primitiveInstance; } if (rawType == Boolean.TYPE) { return BooleanDeserializer.primitiveInstance; } if (rawType == Long.TYPE) { return LongDeserializer.primitiveInstance; } if (rawType == Double.TYPE) { return DoubleDeserializer.primitiveInstance; } if (rawType == Character.TYPE) { return CharacterDeserializer.primitiveInstance; } if (rawType == Byte.TYPE) { return ByteDeserializer.primitiveInstance; } if (raw

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>Type == Short.TYPE) { return ShortDeserializer.primitiveInstance; } if (rawType == Float.TYPE) { return FloatDeserializer.primitiveInstance; } } else if (_classNames.contains(clsName)) { // Start with most common types; int, boolean, long, double if (rawType == Integer.class) { return IntegerDeserializer.wrapperInstance; } if (rawType == Boolean.class) { return BooleanDeserializer.wrapperInstance; } if (rawType == Long.class) { return LongDeserializer.wrapperInstance; } if (rawType == Double.class) { return DoubleDeserializer.wrapperInstance; } if (rawType == Character.class) { return CharacterDeserializer.wrapperInstance; } if (rawType == Byte.class) { return ByteDeserializer.wrapperInstance; } if (rawType == Short.class) { return ShortDeserializer.wrapperInstance; } if (rawType == Float.class) { return FloatDeserializer.wrapperInstance; } if (rawType == Number.class) { return NumberDeserializer.instance; } if (rawType == BigDecimal.class) { return BigDecimalDeserializer.instance; } if (rawType == BigInteger.class) { return BigIntegerDeserializer.instance; } } else { return null; } // should never occur throw new IllegalArgumentException("Internal error: can't find deserializer for "+rawType.getName()); } /* /********************************************************** /* Then one intermediate base class for things that have /* both primitive and wrapper types /********************************************************** */ protected abstract static class PrimitiveOrWrapperDeserializer<T> extends StdScalarDeserializer<T> { private static final long serialVersionUID = 1L; protected final T _nullValue; // @since 2.9 protected final T _emptyValue; protected final boolean _primitive; protected PrimitiveOrWrapperDeserializer(Class<T> vc, T nvl, T empty) { super(vc); _nullValue = nvl; _emptyValue = empty; _primitive = vc.isPrimitive(); } @Override public AccessPattern getNullAccessPattern() { // 02-Feb-2017, tatu: For primitives

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>Writer constructFilteredBeanWriter(BeanPropertyWriter writer, Class<?>[] inViews) { return FilteredBeanPropertyWriter.constructViewBased(writer, inViews); } protected PropertyBuilder constructPropertyBuilder(SerializationConfig config, BeanDescription beanDesc) { return new PropertyBuilder(config, beanDesc); } protected BeanSerializerBuilder constructBeanSerializerBuilder(BeanDescription beanDesc) { return new BeanSerializerBuilder(beanDesc); } /* /********************************************************** /* Overridable non-public introspection methods /********************************************************** */ /** * Helper method used to skip processing for types that we know * can not be (i.e. are never consider to be) beans: * things like primitives, Arrays, Enums, and proxy types. *<p> * Note that usually we shouldn't really be getting these sort of * types anyway; but better safe than sorry. */ protected boolean isPotentialBeanType(Class<?> type) { return (ClassUtil.canBeABeanType(type) == null) && !ClassUtil.isProxyType(type); } /** * Method used to collect all actual serializable properties. * Can be overridden to implement custom detection schemes. */ protected List<BeanPropertyWriter> findBeanProperties(SerializerProvider prov, BeanDescription beanDesc, BeanSerializerBuilder builder) throws JsonMappingException { List<BeanPropertyDefinition> properties = beanDesc.findProperties(); final SerializationConfig config = prov.getConfig(); // ignore specified types removeIgnorableTypes(config, beanDesc, properties); // and possibly remove ones without matching mutator... if (config.isEnabled(MapperFeature.REQUIRE_SETTERS_FOR_GETTERS)) { removeSetterlessGetters(config, beanDesc, properties); } // nothing? can't proceed (caller may or may not throw an exception) if (properties.isEmpty()) { return null; } // null is for value type serializer, which we don't have access to from here (ditto for bean prop) boolean staticTyping = usesStaticTyping(config, beanDesc, null); PropertyBuilder pb = constructPropertyBuilder(config, beanDesc); ArrayList<BeanPropertyWriter> result = new ArrayList<BeanPropertyWriter>(properties.size());

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> public List<AnnotatedMethod> getFactoryMethods() { return _creators().creatorMethods; } /** * @deprecated Since 2.9; use {@link #getFactoryMethods} instead. */ @Deprecated public List<AnnotatedMethod> getStaticMethods() { return getFactoryMethods(); } private final Creators _creators() { Creators c = _creators; if (c == null) { _creators = c = AnnotatedCreatorCollector.collectCreators(_annotationIntrospector, this, _type, _primaryMixIn); } return c; } public Iterable<AnnotatedMethod> memberMethods() { return _methods(); } public int getMemberMethodCount() { return _methods().size(); } public AnnotatedMethod findMethod(String name, Class<?>[] paramTypes) { return _methods().find(name, paramTypes); } private final AnnotatedMethodMap _methods() { AnnotatedMethodMap m = _memberMethods; if (m == null) { _memberMethods = m = AnnotatedMethodCollector.collectMethods(_annotationIntrospector, this, _mixInResolver, _typeFactory, _type, _superTypes, _primaryMixIn); } return m; } public int getFieldCount() { return _fields().size(); } public Iterable<AnnotatedField> fields() { return _fields(); } private final List<AnnotatedField> _fields() { List<AnnotatedField> f = _fields; if (f == null) { _fields = f = AnnotatedFieldCollector.collectFields(_annotationIntrospector, this, _mixInResolver, _typeFactory, _type); } return f; } /** * @since 2.9 */ public boolean isNonStaticInnerClass() { Boolean B = _nonStaticInnerClass; if (B == null) { _nonStaticInnerClass = B = ClassUtil.isNonStaticInnerClass(_class); } return B.booleanValue(); } /* /********************************************************** /* Standard method overrides /********************************************************** */ @Override public String toString() { return "[AnnotedClass "+_class.getName()+"]";

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> } @Override public int hashCode() { return _class.getName().hashCode(); } @Override public boolean equals(Object o) { if (o == this) return true; if (!ClassUtil.hasClass(o, getClass())) { return false; } return ((AnnotatedClass) o)._class == _class; } /* /********************************************************** /* Helper classes /********************************************************** */ public static final class Creators { /** * Default constructor of the annotated class, if it has one. */ public final AnnotatedConstructor defaultConstructor; /** * Single argument constructors the class has, if any. */ public final List<AnnotatedConstructor> constructors; /** * Single argument static methods that might be usable * as factory methods */ public final List<AnnotatedMethod> creatorMethods; public Creators(AnnotatedConstructor defCtor, List<AnnotatedConstructor> ctors, List<AnnotatedMethod> ctorMethods) { defaultConstructor = defCtor; constructors = ctors; creatorMethods = ctorMethods; } } }

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> factory method. And don't check for dups, if we must, * can start checking for them later on. */ Linked<AnnotatedParameter> curr = _ctorParameters; do { if (curr.value.getOwner() instanceof AnnotatedConstructor) { return curr.value; } curr = curr.next; } while (curr != null); return _ctorParameters.value; } @Override public Iterator<AnnotatedParameter> getConstructorParameters() { if (_ctorParameters == null) { return ClassUtil.emptyIterator(); } return new MemberIterator<AnnotatedParameter>(_ctorParameters); } @Override public AnnotatedMember getPrimaryMember() { if (_forSerialization) { return getAccessor(); } AnnotatedMember m = getMutator(); // for setterless properties, however... if (m == null) { m = getAccessor(); } return m; } protected int _getterPriority(AnnotatedMethod m) { final String name = m.getName(); // [databind#238]: Also, regular getters have precedence over "is-getters" if (name.startsWith("get") && name.length() > 3) { // should we check capitalization? return 1; } if (name.startsWith("is") && name.length() > 2) { return 2; } return 3; } protected int _setterPriority(AnnotatedMethod m) { final String name = m.getName(); if (name.startsWith("set") && name.length() > 3) { // should we check capitalization? return 1; } return 2; } /* /********************************************************** /* Implementations of refinement accessors /********************************************************** */ @Override public Class<?>[] findViews() { return fromMemberAnnotations(new WithMember<Class<?>[]>() { @Override public Class<?>[] withMember(AnnotatedMember member) { return _annotationIntrospector.findViews(member); } }); } @Override public AnnotationIntrospector.ReferenceProperty findReferenceType() { // 30-Mar-2017, tatu: Access lazily but retain information since it needs // to

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> = 1L; final protected Class<?> _keyClass; protected final JsonDeserializer<?> _delegate; protected DelegatingKD(Class<?> cls, JsonDeserializer<?> deser) { _keyClass = cls; _delegate = deser; } @SuppressWarnings("resource") @Override public final Object deserializeKey(String key, DeserializationContext ctxt) throws IOException { if (key == null) { // is this even legal call? return null; } TokenBuffer tb = new TokenBuffer(ctxt.getParser(), ctxt); tb.writeString(key); try { // Ugh... should not have to give parser which may or may not be correct one... JsonParser p = tb.asParser(); p.nextToken(); Object result = _delegate.deserialize(p, ctxt); if (result != null) { return result; } return ctxt.handleWeirdKey(_keyClass, key, "not a valid representation"); } catch (Exception re) { return ctxt.handleWeirdKey(_keyClass, key, "not a valid representation: %s", re.getMessage()); } } public Class<?> getKeyClass() { return _keyClass; } } @JacksonStdImpl final static class EnumKD extends StdKeyDeserializer { private static final long serialVersionUID = 1L; protected final EnumResolver _byNameResolver; protected final AnnotatedMethod _factory; /** * Lazily constructed alternative in case there is need to * use 'toString()' method as the source. * * @since 2.7.3 */ protected EnumResolver _byToStringResolver; protected EnumKD(EnumResolver er, AnnotatedMethod factory) { super(-1, er.getEnumClass()); _byNameResolver = er; _factory = factory; } @Override public Object _parse(String key, DeserializationContext ctxt) throws IOException { if (_factory != null) { try { return _factory.call1(key); } catch (Exception e) { ClassUtil.unwrapAndThrowAsIAE(e); } } EnumResolver res = ctxt.isEnabled(DeserializationFeature.READ_ENUMS_USING_TO_STRING) ? _getToStringResolver(ctxt) : _byName

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> for some deserializers this may be further refined. return AccessPattern.DYNAMIC; } @Override // since 2.9 public Object getEmptyValue(DeserializationContext ctxt) throws JsonMappingException { ValueInstantiator vi = getValueInstantiator(); if (vi == null || !vi.canCreateUsingDefault()) { JavaType type = getValueType(); ctxt.reportBadDefinition(type, String.format("Can not create empty instance of %s, no default Creator", type)); } try { return vi.createUsingDefault(ctxt); } catch (IOException e) { return ClassUtil.throwAsMappingException(ctxt, e); } } /* /********************************************************** /* Shared methods for sub-classes /********************************************************** */ /** * Helper method called by various Map(-like) deserializers. */ protected <BOGUS> BOGUS wrapAndThrow(Throwable t, Object ref, String key) throws IOException { // to handle StackOverflow: while (t instanceof InvocationTargetException && t.getCause() != null) { t = t.getCause(); } // Errors and "plain" IOExceptions to be passed as is ClassUtil.throwIfError(t); // ... except for mapping exceptions if (t instanceof IOException && !(t instanceof JsonMappingException)) { throw (IOException) t; } // for [databind#1141] throw JsonMappingException.wrapWithPath(t, ref, ClassUtil.nonNull(key, "N/A")); } }

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> for actual serialization, by delegating * calls. If so, will return immediate delegate (which itself may * delegate to further serializers); otherwise will return null. * * @return Serializer this serializer delegates calls to, if null; * null otherwise. * * @since 2.1 */ public JsonSerializer<?> getDelegatee() { return null; } /** * Accessor for iterating over logical properties that the type * handled by this serializer has, from serialization perspective. * Actual type of properties, if any, will be * {@link com.fasterxml.jackson.databind.ser.BeanPropertyWriter}. * Of standard Jackson serializers, only {@link com.fasterxml.jackson.databind.ser.BeanSerializer} * exposes properties. * * @since 2.6 */ public Iterator<PropertyWriter> properties() { return ClassUtil.emptyIterator(); } /* /********************************************************** /* Default JsonFormatVisitable implementation /********************************************************** */ /** * Default implementation simply calls {@link JsonFormatVisitorWrapper#expectAnyFormat(JavaType)}. * * @since 2.1 */ @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType type) throws JsonMappingException { visitor.expectAnyFormat(type); } /* /********************************************************** /* Helper class(es) /********************************************************** */ /** * This marker class is only to be used with annotations, to * indicate that <b>no serializer is configured</b>. *<p> * Specifically, this class is to be used as the marker for * annotation {@link com.fasterxml.jackson.databind.annotation.JsonSerialize}. */ public abstract static class None extends JsonSerializer<Object> { } }

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>package com.fasterxml.jackson.databind.introspect; import java.lang.annotation.Annotation; import java.lang.annotation.Retention; import java.lang.annotation.Target; import com.fasterxml.jackson.databind.AnnotationIntrospector; import com.fasterxml.jackson.databind.util.ClassUtil; // @since 2.9 class CollectorBase { protected final static AnnotationMap[] NO_ANNOTATION_MAPS = new AnnotationMap[0]; protected final static Annotation[] NO_ANNOTATIONS = new Annotation[0]; protected final AnnotationIntrospector _intr; protected CollectorBase(AnnotationIntrospector intr) { _intr = intr; } // // // Annotation overrides ("mix over") protected final AnnotationCollector collectAnnotations(Annotation[] anns) { AnnotationCollector c = AnnotationCollector.emptyCollector(); for (int i = 0, end = anns.length; i < end; ++i) { Annotation ann = anns[i]; c = c.addOrOverride(ann); if (_intr.isAnnotationBundle(ann)) { c = collectFromBundle(c, ann); } } return c; } protected final AnnotationCollector collectAnnotations(AnnotationCollector c, Annotation[] anns) { for (int i = 0, end = anns.length; i < end; ++i) { Annotation ann = anns[i]; c = c.addOrOverride(ann); if (_intr.isAnnotationBundle(ann)) { c = collectFromBundle(c, ann); } } return c; } protected final AnnotationCollector collectFromBundle(AnnotationCollector c, Annotation bundle) { Annotation[] anns = ClassUtil.findClassAnnotations(bundle.annotationType()); for (int i = 0, end = anns.length; i < end; ++i) { Annotation ann = anns[i]; // minor optimization: by-pass 2 common JDK meta-annotations if (_ignorableAnnotation(ann)) { continue; } if (_intr.isAnnotationBundle(ann)) { // 11-Apr-2017, tatu: Also must guard against recursive definitions... if (!c.isPresent(ann)) { c = c

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>.addOrOverride(ann); c = collectFromBundle(c, ann); } } else { c = c.addOrOverride(ann); } } return c; } // // // Defaulting ("mix under") // Variant that only adds annotations that are missing protected final AnnotationCollector collectDefaultAnnotations(AnnotationCollector c, Annotation[] anns) { for (int i = 0, end = anns.length; i < end; ++i) { Annotation ann = anns[i]; if (!c.isPresent(ann)) { c = c.addOrOverride(ann); if (_intr.isAnnotationBundle(ann)) { c = collectDefaultFromBundle(c, ann); } } } return c; } protected final AnnotationCollector collectDefaultFromBundle(AnnotationCollector c, Annotation bundle) { Annotation[] anns = ClassUtil.findClassAnnotations(bundle.annotationType()); for (int i = 0, end = anns.length; i < end; ++i) { Annotation ann = anns[i]; // minor optimization: by-pass 2 common JDK meta-annotations if (_ignorableAnnotation(ann)) { continue; } // also only defaulting, not overrides: if (!c.isPresent(ann)) { c = c.addOrOverride(ann); if (_intr.isAnnotationBundle(ann)) { c = collectFromBundle(c, ann); } } } return c; } protected final static boolean _ignorableAnnotation(Annotation a) { return (a instanceof Target) || (a instanceof Retention); } static AnnotationMap _emptyAnnotationMap() { return new AnnotationMap(); } static AnnotationMap[] _emptyAnnotationMaps(int count) { if (count == 0) { return NO_ANNOTATION_MAPS; } AnnotationMap[] maps = new AnnotationMap[count]; for (int i = 0; i < count; ++i) { maps[i] = _emptyAnnotationMap(); } return maps; } }

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>type; } @Deprecated @Override public Type getGenericType() { return _owner.getGenericParameterType(_index); } /* /********************************************************** /* AnnotatedMember extras /********************************************************** */ @Override public Class<?> getDeclaringClass() { return _owner.getDeclaringClass(); } @Override public Member getMember() { /* This is bit tricky: since there is no JDK equivalent; can either * return null or owner... let's do latter, for now. */ return _owner.getMember(); } @Override public void setValue(Object pojo, Object value) throws UnsupportedOperationException { throw new UnsupportedOperationException("Cannot call setValue() on constructor parameter of " +getDeclaringClass().getName()); } @Override public Object getValue(Object pojo) throws UnsupportedOperationException { throw new UnsupportedOperationException("Cannot call getValue() on constructor parameter of " +getDeclaringClass().getName()); } /* /********************************************************** /* Extended API /********************************************************** */ public Type getParameterType() { return _type; } /** * Accessor for 'owner' of this parameter; method or constructor that * has this parameter as member of its argument list. * * @return Owner (member or creator) object of this parameter */ public AnnotatedWithParams getOwner() { return _owner; } /** * Accessor for index of this parameter within argument list * * @return Index of this parameter within argument list */ public int getIndex() { return _index; } /* /******************************************************** /* Other /******************************************************** */ @Override public int hashCode() { return _owner.hashCode() + _index; } @Override public boolean equals(Object o) { if (o == this) return true; if (!ClassUtil.hasClass(o, getClass())) { return false; } AnnotatedParameter other = (AnnotatedParameter) o; return other._owner.equals(_owner) && (other._index == _index); } @Override public String toString() { return "[parameter #"+getIndex()+", annotations: "+_annotations+"]"; } }

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> if annotations not enabled; if so, can skip: if (_intr != null) { if (_defaultConstructor != null) { if (_intr.hasIgnoreMarker(_defaultConstructor)) { _defaultConstructor = null; } } // count down to allow safe removal for (int i = constructors.size(); --i >= 0; ) { if (_intr.hasIgnoreMarker(constructors.get(i))) { constructors.remove(i); } } for (int i = factories.size(); --i >= 0; ) { if (_intr.hasIgnoreMarker(factories.get(i))) { factories.remove(i); } } } return new AnnotatedClass.Creators(_defaultConstructor, constructors, factories); } /** * Helper method for locating constructors (and matching mix-in overrides) * we might want to use; this is needed in order to mix information between * the two and construct resulting {@link AnnotatedConstructor}s */ private List<AnnotatedConstructor> _findPotentialConstructors(JavaType type, Class<?> primaryMixIn) { ClassUtil.Ctor defaultCtor = null; List<ClassUtil.Ctor> ctors = null; // 18-Jun-2016, tatu: Enum constructors will never be useful (unlike // possibly static factory methods); but they can be royal PITA // due to some oddities by JVM; see: // [https://github.com/FasterXML/jackson-module-parameter-names/issues/35] // for more. So, let's just skip them. if (!type.isEnumType()) { ClassUtil.Ctor[] declaredCtors = ClassUtil.getConstructors(type.getRawClass()); for (ClassUtil.Ctor ctor : declaredCtors) { if (!isIncludableConstructor(ctor.getConstructor())) { continue; } if (ctor.getParamCount() == 0) { defaultCtor = ctor; } else { if (ctors == null) { ctors = new ArrayList<>(); } ctors.add(ctor); } } } List<AnnotatedConstructor> result; int ctorCount; if (ctors == null) {

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> result = Collections.emptyList(); // Nothing found? Short-circuit if (defaultCtor == null) { return result; } ctorCount = 0; } else { ctorCount = ctors.size(); result = new ArrayList<>(ctorCount); for (int i = 0; i < ctorCount; ++i) { result.add(null); } } // so far so good; but do we also need to find mix-ins overrides? if (primaryMixIn != null) { MemberKey[] ctorKeys = null; for (ClassUtil.Ctor mixinCtor : ClassUtil.getConstructors(primaryMixIn)) { if (mixinCtor.getParamCount() == 0) { if (defaultCtor != null) { _defaultConstructor = constructDefaultConstructor(defaultCtor, mixinCtor); defaultCtor = null; } continue; } if (ctors != null) { if (ctorKeys == null) { ctorKeys = new MemberKey[ctorCount]; for (int i = 0; i < ctorCount; ++i) { ctorKeys[i] = new MemberKey(ctors.get(i).getConstructor()); } } MemberKey key = new MemberKey(mixinCtor.getConstructor()); for (int i = 0; i < ctorCount; ++i) { if (key.equals(ctorKeys[i])) { result.set(i, constructNonDefaultConstructor(ctors.get(i), mixinCtor)); break; } } } } } // Ok: anything within mix-ins has been resolved; anything remaining we must resolve if (defaultCtor != null) { _defaultConstructor = constructDefaultConstructor(defaultCtor, null); } for (int i = 0; i < ctorCount; ++i) { AnnotatedConstructor ctor = result.get(i); if (ctor == null) { result.set(i, constructNonDefaultConstructor(ctors.get(i), null)); } } return result; } private List<AnnotatedMethod> _findPotentialFactories(JavaType type, Class<?> primaryMixIn) { List<Method> candidates = null; // First find all potentially relevant static methods for (Method m :

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> ClassUtil.getClassMethods(type.getRawClass())) { if (!Modifier.isStatic(m.getModifiers())) { continue; } // all factory methods are fine: //int argCount = m.getParameterTypes().length; if (candidates == null) { candidates = new ArrayList<>(); } candidates.add(m); } // and then locate mix-ins, if any if (candidates == null) { return Collections.emptyList(); } int factoryCount = candidates.size(); List<AnnotatedMethod> result = new ArrayList<>(factoryCount); for (int i = 0; i < factoryCount; ++i) { result.add(null); } // so far so good; but do we also need to find mix-ins overrides? if (primaryMixIn != null) { MemberKey[] methodKeys = null; for (Method mixinFactory : ClassUtil.getDeclaredMethods(primaryMixIn)) { if (!Modifier.isStatic(mixinFactory.getModifiers())) { continue; } if (methodKeys == null) { methodKeys = new MemberKey[factoryCount]; for (int i = 0; i < factoryCount; ++i) { methodKeys[i] = new MemberKey(candidates.get(i)); } } MemberKey key = new MemberKey(mixinFactory); for (int i = 0; i < factoryCount; ++i) { if (key.equals(methodKeys[i])) { result.set(i, constructFactoryCreator(candidates.get(i), mixinFactory)); break; } } } } // Ok: anything within mix-ins has been resolved; anything remaining we must resolve for (int i = 0; i < factoryCount; ++i) { AnnotatedMethod factory = result.get(i); if (factory == null) { result.set(i, constructFactoryCreator(candidates.get(i), null)); } } return result; } protected AnnotatedConstructor constructDefaultConstructor(ClassUtil.Ctor ctor, ClassUtil.Ctor mixin) { if (_intr == null) { // when annotation processing is disabled return new AnnotatedConstructor(_typeContext, ctor.getConstructor(), _emptyAnnotationMap(),

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> NO_ANNOTATION_MAPS); } return new AnnotatedConstructor(_typeContext, ctor.getConstructor(), collectAnnotations(ctor, mixin), collectAnnotations(ctor.getConstructor().getParameterAnnotations(), (mixin == null) ? null : mixin.getConstructor().getParameterAnnotations())); } protected AnnotatedConstructor constructNonDefaultConstructor(ClassUtil.Ctor ctor, ClassUtil.Ctor mixin) { final int paramCount = ctor.getParamCount(); if (_intr == null) { // when annotation processing is disabled return new AnnotatedConstructor(_typeContext, ctor.getConstructor(), _emptyAnnotationMap(), _emptyAnnotationMaps(paramCount)); } /* Looks like JDK has discrepancy, whereas annotations for implicit 'this' * (for non-static inner classes) are NOT included, but type is? * Strange, sounds like a bug. Alas, we can't really fix that... */ if (paramCount == 0) { // no-arg default constructors, can simplify slightly return new AnnotatedConstructor(_typeContext, ctor.getConstructor(), collectAnnotations(ctor, mixin), NO_ANNOTATION_MAPS); } // Also: enum value constructors AnnotationMap[] resolvedAnnotations; Annotation[][] paramAnns = ctor.getParameterAnnotations(); if (paramCount != paramAnns.length) { // Limits of the work-around (to avoid hiding real errors): // first, only applicable for member classes and then either: resolvedAnnotations = null; Class<?> dc = ctor.getDeclaringClass(); // (a) is enum, which have two extra hidden params (name, index) if (dc.isEnum() && (paramCount == paramAnns.length + 2)) { Annotation[][] old = paramAnns; paramAnns = new Annotation[old.length+2][]; System.arraycopy(old, 0, paramAnns, 2, old.length); resolvedAnnotations = collectAnnotations(paramAnns, null); } else if (dc.isMemberClass()) { // (b) non-static inner classes, get implicit 'this' for parameter, not annotation if (paramCount == (paramAnns.length + 1)) { // hack attack: prepend a null entry to make things match

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>Map collectAnnotations(ClassUtil.Ctor main, ClassUtil.Ctor mixin) { AnnotationCollector c = collectAnnotations(main.getConstructor().getDeclaredAnnotations()); if (mixin != null) { c = collectAnnotations(c, mixin.getConstructor().getDeclaredAnnotations()); } return c.asAnnotationMap(); } private final AnnotationMap collectAnnotations(AnnotatedElement main, AnnotatedElement mixin) { AnnotationCollector c = collectAnnotations(main.getDeclaredAnnotations()); if (mixin != null) { c = collectAnnotations(c, mixin.getDeclaredAnnotations()); } return c.asAnnotationMap(); } // for [databind#1005]: do not use or expose synthetic constructors private static boolean isIncludableConstructor(Constructor<?> c) { return !c.isSynthetic(); } }

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> * StackOverflow: usually due to infinite loop. But that * usually gets hidden within an InvocationTargetException... */ while (t instanceof InvocationTargetException && t.getCause() != null) { t = t.getCause(); } // Errors and "plain" to be passed as is ClassUtil.throwIfError(t); // Ditto for IOExceptions... except for mapping exceptions! boolean wrap = (provider == null) || provider.isEnabled(SerializationFeature.WRAP_EXCEPTIONS); if (t instanceof IOException) { if (!wrap || !(t instanceof JsonMappingException)) { throw (IOException) t; } } else if (!wrap) { ClassUtil.throwIfRTE(t); } // Need to add reference information throw JsonMappingException.wrapWithPath(t, bean, fieldName); } public void wrapAndThrow(SerializerProvider provider, Throwable t, Object bean, int index) throws IOException { while (t instanceof InvocationTargetException && t.getCause() != null) { t = t.getCause(); } // Errors are to be passed as is ClassUtil.throwIfError(t); // Ditto for IOExceptions... except for mapping exceptions! boolean wrap = (provider == null) || provider.isEnabled(SerializationFeature.WRAP_EXCEPTIONS); if (t instanceof IOException) { if (!wrap || !(t instanceof JsonMappingException)) { throw (IOException) t; } } else if (!wrap) { ClassUtil.throwIfRTE(t); } // Need to add reference information throw JsonMappingException.wrapWithPath(t, bean, index); } /* /********************************************************** /* Helper methods, accessing annotation-based configuration /********************************************************** */ /** * Helper method that can be used to see if specified property has annotation * indicating that a converter is to be used for contained values (contents * of structured types; array/List/Map values) * * @param existingSerializer (optional) configured content * serializer if one already exists. * * @since 2.9 */ protected JsonSerializer<?> findContextualConvertingSerializer(SerializerProvider provider, BeanProperty property, JsonSerializer<?> existingSerializer) throws JsonMappingException { // 08-Dec

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> } // even without property or AnnotationIntrospector, may have type-specific defaults return provider.getDefaultPropertyInclusion(typeForDefaults); } /** * Convenience method for finding out possibly configured content value serializer. * * @since 2.7.4 */ protected JsonSerializer<?> findAnnotatedContentSerializer(SerializerProvider serializers, BeanProperty property) throws JsonMappingException { if (property != null) { // First: if we have a property, may have property-annotation overrides AnnotatedMember m = property.getMember(); final AnnotationIntrospector intr = serializers.getAnnotationIntrospector(); if (m != null) { Object serDef = intr.findContentSerializer(m); if (serDef != null) { return serializers.serializerInstance(m, serDef); } } } return null; } /* /********************************************************** /* Helper methods, other /********************************************************** */ /** * Method that can be called to determine if given serializer is the default * serializer Jackson uses; as opposed to a custom serializer installed by * a module or calling application. Determination is done using * {@link JacksonStdImpl} annotation on serializer class. */ protected boolean isDefaultSerializer(JsonSerializer<?> serializer) { return ClassUtil.isJacksonStdImpl(serializer); } /** * @since 2.9 */ protected final static boolean _neitherNull(Object a, Object b) { return (a != null) && (b != null); } /** * @since 2.9 */ protected final static boolean _nonEmpty(Collection<?> c) { return (c != null) && !c.isEmpty(); } }

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>2.9 */ @SuppressWarnings("unchecked") protected Collection<Object> createDefaultInstance(DeserializationContext ctxt) throws IOException { return (Collection<Object>) _valueInstantiator.createUsingDefault(ctxt); } @Override public Collection<Object> deserialize(JsonParser p, DeserializationContext ctxt, Collection<Object> result) throws IOException { // Ok: must point to START_ARRAY (or equivalent) if (!p.isExpectedStartArrayToken()) { return handleNonArray(p, ctxt, result); } // [databind#631]: Assign current value, to be accessible by custom serializers p.setCurrentValue(result); JsonDeserializer<Object> valueDes = _valueDeserializer; final TypeDeserializer typeDeser = _valueTypeDeserializer; CollectionReferringAccumulator referringAccumulator = (valueDes.getObjectIdReader() == null) ? null : new CollectionReferringAccumulator(_containerType.getContentType().getRawClass(), result); JsonToken t; while ((t = p.nextToken()) != JsonToken.END_ARRAY) { try { Object value; if (t == JsonToken.VALUE_NULL) { if (_skipNullValues) { continue; } value = _nullProvider.getNullValue(ctxt); } else if (typeDeser == null) { value = valueDes.deserialize(p, ctxt); } else { value = valueDes.deserializeWithType(p, ctxt, typeDeser); } if (referringAccumulator != null) { referringAccumulator.add(value); } else { result.add(value); } } catch (UnresolvedForwardReference reference) { if (referringAccumulator == null) { throw JsonMappingException .from(p, "Unresolved forward reference but no identity info", reference); } Referring ref = referringAccumulator.handleUnresolvedReference(reference); reference.getRoid().appendReferring(ref); } catch (Exception e) { boolean wrap = (ctxt == null) || ctxt.isEnabled(DeserializationFeature.WRAP_EXCEPTIONS); if (!wrap) { ClassUtil.throwIfRTE(e); } throw JsonMappingException.wrapWithPath(e, result, result.size()); } } return result;

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>Name(newName); JsonDeserializer<?> deser = prop.getValueDeserializer(); if (deser != null) { @SuppressWarnings("unchecked") JsonDeserializer<Object> newDeser = (JsonDeserializer<Object>) deser.unwrappingDeserializer(xf); if (newDeser != deser) { prop = prop.withValueDeserializer(newDeser); } } return prop; } protected void wrapAndThrow(Throwable t, Object bean, String fieldName, DeserializationContext ctxt) throws IOException { // inlined 'throwOrReturnThrowable' while (t instanceof InvocationTargetException && t.getCause() != null) { t = t.getCause(); } // Errors to be passed as is ClassUtil.throwIfError(t); // StackOverflowErrors are tricky ones; need to be careful... boolean wrap = (ctxt == null) || ctxt.isEnabled(DeserializationFeature.WRAP_EXCEPTIONS); // Ditto for IOExceptions; except we may want to wrap JSON exceptions if (t instanceof IOException) { if (!wrap || !(t instanceof JsonProcessingException)) { throw (IOException) t; } } else if (!wrap) { // allow disabling wrapping for unchecked exceptions ClassUtil.throwIfRTE(t); } throw JsonMappingException.wrapWithPath(t, bean, fieldName); } /** * Helper method used to find exact location of a property with name * given exactly, not subject to case changes, within hash area. * Expectation is that such property SHOULD exist, although no * exception is thrown. * * @since 2.7 */ private final int _findIndexInHash(String key) { final int slot = _hashCode(key); int ix = (slot<<1); // primary match? if (key.equals(_hashArea[ix])) { return ix+1; } // no? secondary? int hashSize = _hashMask+1; ix = hashSize + (slot>>1) << 1; if (key.equals(_hashArea[ix])) { return ix+1; } // perhaps spill then int i = (hashSize + (hashSize>>1)) << 1; for (int end = i + _spillCount

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> parameter #"+index+" of "+owner +" bound to more than one property; "+defs[index]+" vs "+propDef); } } defs[index] = propDef; } } return result; } public ValueInstantiator _valueInstantiatorInstance(DeserializationConfig config, Annotated annotated, Object instDef) throws JsonMappingException { if (instDef == null) { return null; } ValueInstantiator inst; if (instDef instanceof ValueInstantiator) { return (ValueInstantiator) instDef; } if (!(instDef instanceof Class)) { throw new IllegalStateException("AnnotationIntrospector returned key deserializer definition of type " +instDef.getClass().getName() +"; expected type KeyDeserializer or Class<KeyDeserializer> instead"); } Class<?> instClass = (Class<?>)instDef; if (ClassUtil.isBogusClass(instClass)) { return null; } if (!ValueInstantiator.class.isAssignableFrom(instClass)) { throw new IllegalStateException("AnnotationIntrospector returned Class "+instClass.getName() +"; expected Class<ValueInstantiator>"); } HandlerInstantiator hi = config.getHandlerInstantiator(); if (hi != null) { inst = hi.valueInstantiatorInstance(config, annotated, instClass); if (inst != null) { return inst; } } return (ValueInstantiator) ClassUtil.createInstance(instClass, config.canOverrideAccessModifiers()); } protected void _addDeserializerConstructors (DeserializationContext ctxt, BeanDescription beanDesc, VisibilityChecker<?> vchecker, AnnotationIntrospector intr, CreatorCollector creators, Map<AnnotatedWithParams,BeanPropertyDefinition[]> creatorParams) throws JsonMappingException { // First things first: the "default constructor" (zero-arg // constructor; whether implicit or explicit) is NOT included // in list of constructors, so needs to be handled separately. AnnotatedConstructor defaultCtor = beanDesc.findDefaultConstructor(); if (defaultCtor != null) { if (!creators.hasDefaultCreator() || _hasCreatorAnnotation(ctxt, defaultCtor)) { creators.setDefaultCreator(defaultCtor); } } // 25-Jan-2017, t

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> @Override public JsonDeserializer<?> createArrayDeserializer(DeserializationContext ctxt, ArrayType type, final BeanDescription beanDesc) throws JsonMappingException { final DeserializationConfig config = ctxt.getConfig(); JavaType elemType = type.getContentType(); // Very first thing: is deserializer hard-coded for elements? JsonDeserializer<Object> contentDeser = elemType.getValueHandler(); // Then optional type info: if type has been resolved, we may already know type deserializer: TypeDeserializer elemTypeDeser = elemType.getTypeHandler(); // but if not, may still be possible to find: if (elemTypeDeser == null) { elemTypeDeser = findTypeDeserializer(config, elemType); } // 23-Nov-2010, tatu: Custom array deserializer? JsonDeserializer<?> deser = _findCustomArrayDeserializer(type, config, beanDesc, elemTypeDeser, contentDeser); if (deser == null) { if (contentDeser == null) { Class<?> raw = elemType.getRawClass(); if (elemType.isPrimitive()) { return PrimitiveArrayDeserializers.forType(raw); } else if (raw == String.class) { return StringArrayDeserializer.instance; } } deser = new ObjectArrayDeserializer(type, contentDeser, elemTypeDeser); } // and then new with 2.2: ability to post-process it too (Issue#120) if (_factoryConfig.hasDeserializerModifiers()) { for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { deser = mod.modifyArrayDeserializer(config, type, beanDesc, deser); } } return deser; } /* /********************************************************** /* JsonDeserializerFactory impl: Collection(-like) deserializers /********************************************************** */ @Override public JsonDeserializer<?> createCollectionDeserializer(DeserializationContext ctxt, CollectionType type, BeanDescription beanDesc) throws JsonMappingException { JavaType contentType = type.getContentType(); // Very first thing: is deserializer hard-coded for elements? JsonDeserializer<Object> contentDeser = contentType.getValueHandler(); final DeserializationConfig config = ctxt.getConfig(); // Then optional type info: if

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>, config, beanDesc.findJsonValueAccessor()); // May have @JsonCreator for static factory method: for (AnnotatedMethod factory : beanDesc.getFactoryMethods()) { if (_hasCreatorAnnotation(ctxt, factory)) { int argCount = factory.getParameterCount(); if (argCount == 1) { Class<?> returnType = factory.getRawReturnType(); // usually should be class, but may be just plain Enum<?> (for Enum.valueOf()?) if (returnType.isAssignableFrom(enumClass)) { // note: mostly copied from 'EnumDeserializer.deserializerForCreator(...)' if (factory.getRawParameterType(0) != String.class) { throw new IllegalArgumentException("Parameter #0 type for factory method ("+factory+") not suitable, must be java.lang.String"); } if (config.canOverrideAccessModifiers()) { ClassUtil.checkAndFixAccess(factory.getMember(), ctxt.isEnabled(MapperFeature.OVERRIDE_PUBLIC_ACCESS_MODIFIERS)); } return StdKeyDeserializers.constructEnumKeyDeserializer(enumRes, factory); } } throw new IllegalArgumentException("Unsuitable method ("+factory+") decorated with @JsonCreator (for Enum type " +enumClass.getName()+")"); } } // Also, need to consider @JsonValue, if one found return StdKeyDeserializers.constructEnumKeyDeserializer(enumRes); } /* /********************************************************** /* Extended API /********************************************************** */ /** * Method called to create a type information deserializer for values of * given non-container property, if one is needed. * If not needed (no polymorphic handling configured for property), should return null. *<p> * Note that this method is only called for non-container bean properties, * and not for values in container types or root values (or container properties) * * @param baseType Declared base type of the value to deserializer (actual * deserializer type will be this type or its subtype) * * @return Type deserializer to use for given base type, if one is needed; null if not. */ public TypeDeserializer findPropertyTypeDeserializer(DeserializationConfig config, JavaType baseType, AnnotatedMember annotated) throws JsonMappingException { AnnotationIntrospector ai = config.getAnnotationInt

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>.getRawClass(); // Object ("untyped"), String equivalents: if (rawType == CLASS_OBJECT) { // 11-Feb-2015, tatu: As per [databind#700] need to be careful wrt non-default Map, List. DeserializationConfig config = ctxt.getConfig(); JavaType lt, mt; if (_factoryConfig.hasAbstractTypeResolvers()) { lt = _findRemappedType(config, List.class); mt = _findRemappedType(config, Map.class); } else { lt = mt = null; } return new UntypedObjectDeserializer(lt, mt); } if (rawType == CLASS_STRING || rawType == CLASS_CHAR_BUFFER) { return StringDeserializer.instance; } if (rawType == CLASS_ITERABLE) { // [databind#199]: Can and should 'upgrade' to a Collection type: TypeFactory tf = ctxt.getTypeFactory(); JavaType[] tps = tf.findTypeParameters(type, CLASS_ITERABLE); JavaType elemType = (tps == null || tps.length != 1) ? TypeFactory.unknownType() : tps[0]; CollectionType ct = tf.constructCollectionType(Collection.class, elemType); // Should we re-introspect beanDesc? For now let's not... return createCollectionDeserializer(ctxt, ct, beanDesc); } if (rawType == CLASS_MAP_ENTRY) { // 28-Apr-2015, tatu: TypeFactory does it all for us already so JavaType kt = type.containedTypeOrUnknown(0); JavaType vt = type.containedTypeOrUnknown(1); TypeDeserializer vts = (TypeDeserializer) vt.getTypeHandler(); if (vts == null) { vts = findTypeDeserializer(ctxt.getConfig(), vt); } JsonDeserializer<Object> valueDeser = vt.getValueHandler(); KeyDeserializer keyDes = (KeyDeserializer) kt.getValueHandler(); return new MapEntryDeserializer(type, keyDes, valueDeser, vts); } String clsName = rawType.getName(); if (rawType.isPrimitive() || clsName.startsWith("java.")) {

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>( ctxt.getConfig(), type, (AnnotatedMember) member); if (contentTypeDeser != null) { type = type.withContentTypeHandler(contentTypeDeser); } } TypeDeserializer valueTypeDeser = findPropertyTypeDeserializer(ctxt.getConfig(), type, (AnnotatedMember) member); if (valueTypeDeser != null) { type = type.withTypeHandler(valueTypeDeser); } // Second part: find actual type-override annotations on member, if any // 18-Jun-2016, tatu: Should we re-do checks for annotations on refined // subtypes as well? Code pre-2.8 did not do this, but if we get bug // reports may need to consider type = intr.refineDeserializationType(ctxt.getConfig(), member, type); return type; } protected EnumResolver constructEnumResolver(Class<?> enumClass, DeserializationConfig config, AnnotatedMember jsonValueAccessor) { if (jsonValueAccessor != null) { if (config.canOverrideAccessModifiers()) { ClassUtil.checkAndFixAccess(jsonValueAccessor.getMember(), config.isEnabled(MapperFeature.OVERRIDE_PUBLIC_ACCESS_MODIFIERS)); } return EnumResolver.constructUnsafeUsingMethod(enumClass, jsonValueAccessor, config.getAnnotationIntrospector()); } // 14-Mar-2016, tatu: We used to check `DeserializationFeature.READ_ENUMS_USING_TO_STRING` // here, but that won't do: it must be dynamically changeable... return EnumResolver.constructUnsafe(enumClass, config.getAnnotationIntrospector()); } /** * @since 2.9 */ protected boolean _hasCreatorAnnotation(DeserializationContext ctxt, Annotated ann) { AnnotationIntrospector intr = ctxt.getAnnotationIntrospector(); if (intr != null) { JsonCreator.Mode mode = intr.findCreatorAnnotation(ctxt.getConfig(), ann); return (mode != null) && (mode != JsonCreator.Mode.DISABLED); } return false; } /* /********************************************************** /* Deprecated helper methods /********************************************************** */ /** * Method called to see if given method has annotations that indicate * a

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> boolean hasField(); public abstract boolean hasConstructorParameter(); public abstract AnnotatedMethod getGetter(); public abstract AnnotatedMethod getSetter(); public abstract AnnotatedField getField(); public abstract AnnotatedParameter getConstructorParameter(); /** * Additional method that may be called instead of {@link #getConstructorParameter()} * to get access to all constructor parameters, not just the highest priority one. * * @since 2.5 */ public Iterator<AnnotatedParameter> getConstructorParameters() { return ClassUtil.emptyIterator(); } /** * Method used to find accessor (getter, field to access) to use for accessing * value of the property. * Null if no such member exists. */ public AnnotatedMember getAccessor() { AnnotatedMember m = getGetter(); if (m == null) { m = getField(); } return m; } /** * Method used to find mutator (constructor parameter, setter, field) to use for * changing value of the property. * Null if no such member exists. */ public AnnotatedMember getMutator() { AnnotatedMember acc = getConstructorParameter(); if (acc == null) { acc = getSetter(); if (acc == null) { acc = getField(); } } return acc; } /** * @since 2.3 */ public AnnotatedMember getNonConstructorMutator() { AnnotatedMember m = getSetter(); if (m == null) { m = getField(); } return m; } /** * Method used to find the property member (getter, setter, field) that has * the highest precedence in current context (getter method when serializing, * if available, and so forth), if any. *<p> * Note: abstract since 2.5 * * @since 2.1 */ public abstract AnnotatedMember getPrimaryMember(); /* /********************************************************** /* More refined access to configuration features /* (usually based on annotations and/or config overrides) /* Since most trivial implementations do not support /* these methods, they are implemented as no-ops. /********************************************************** */ /** * Method used to find View-inclusion definitions for the property.

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> Type[] types = _constructor.getGenericParameterTypes(); if (index >= types.length) { return null; } return _typeContext.resolveType(types[index]); } @Override @Deprecated // since 2.7 public Type getGenericParameterType(int index) { Type[] types = _constructor.getGenericParameterTypes(); if (index >= types.length) { return null; } return types[index]; } @Override public final Object call() throws Exception { return _constructor.newInstance(); } @Override public final Object call(Object[] args) throws Exception { return _constructor.newInstance(args); } @Override public final Object call1(Object arg) throws Exception { return _constructor.newInstance(arg); } /* /********************************************************** /* AnnotatedMember impl /********************************************************** */ @Override public Class<?> getDeclaringClass() { return _constructor.getDeclaringClass(); } @Override public Member getMember() { return _constructor; } @Override public void setValue(Object pojo, Object value) throws UnsupportedOperationException { throw new UnsupportedOperationException("Cannot call setValue() on constructor of " +getDeclaringClass().getName()); } @Override public Object getValue(Object pojo) throws UnsupportedOperationException { throw new UnsupportedOperationException("Cannot call getValue() on constructor of " +getDeclaringClass().getName()); } /* /********************************************************** /* Extended API, specific annotations /********************************************************** */ @Override public String toString() { return "[constructor for "+getName()+", annotations: "+_annotations+"]"; } @Override public int hashCode() { return _constructor.getName().hashCode(); } @Override public boolean equals(Object o) { if (o == this) return true; return ClassUtil.hasClass(o, getClass()) && (((AnnotatedConstructor) o)._constructor == _constructor); } /* /********************************************************** /* JDK serialization handling /********************************************************** */ Object writeReplace() { return new AnnotatedConstructor(new Serialization(_constructor)); } Object readResolve() { Class<?> clazz = _serialization.clazz; try { Constructor<?> ctor = clazz.getDeclaredConstructor(_serialization.args); // 0

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS>6-Oct-2012, tatu: Has "lost" its security override, must force back if (!ctor.isAccessible()) { ClassUtil.checkAndFixAccess(ctor, false); } return new AnnotatedConstructor(null, ctor, null, null); } catch (Exception e) { throw new IllegalArgumentException("Could not find constructor with " +_serialization.args.length+" args from Class '"+clazz.getName()); } } /** * Helper class that is used as the workaround to persist * Field references. It basically just stores declaring class * and field name. */ private final static class Serialization implements java.io.Serializable { private static final long serialVersionUID = 1L; protected Class<?> clazz; protected Class<?>[] args; public Serialization(Constructor<?> ctor) { clazz = ctor.getDeclaringClass(); args = ctor.getParameterTypes(); } } }

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> enums = new LinkedHashSet<String>(); for (Object en : enumType.getEnumConstants()) { try { // 21-Apr-2016, tatu: This is convoluted to the max, but essentially we // call `@JsonValue`-annotated accessor method on all Enum members, // so it all "works out". To some degree. enums.add(String.valueOf(_accessor.getValue(en))); } catch (Exception e) { Throwable t = e; while (t instanceof InvocationTargetException && t.getCause() != null) { t = t.getCause(); } ClassUtil.throwIfError(t); throw JsonMappingException.wrapWithPath(t, en, _accessor.getName() + "()"); } } stringVisitor.enumTypes(enums); } return true; } protected boolean isNaturalTypeWithStdHandling(Class<?> rawType, JsonSerializer<?> ser) { // First: do we have a natural type being handled? if (rawType.isPrimitive()) { if (rawType != Integer.TYPE && rawType != Boolean.TYPE && rawType != Double.TYPE) { return false; } } else { if (rawType != String.class && rawType != Integer.class && rawType != Boolean.class && rawType != Double.class) { return false; } } return isDefaultSerializer(ser); } /* /********************************************************** /* Other methods /********************************************************** */ @Override public String toString() { return "(@JsonValue serializer for method " + _accessor.getDeclaringClass() + "#" + _accessor.getName() + ")"; } /* /********************************************************** /* Helper class /********************************************************** */ /** * Silly little wrapper class we need to re-route type serialization so that we can * override Object to use for type id (logical type) even when asking serialization * of something else (delegate type) */ static class TypeSerializerRerouter extends TypeSerializer { protected final TypeSerializer _typeSerializer; protected final Object _forObject; public TypeSerializerRerouter(TypeSerializer ts, Object ob) { _typeSerializer = ts; _forObject = ob; } @Override public

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> takes {@link JavaType} instead */ @Deprecated public StdValueInstantiator(DeserializationConfig config, Class<?> valueType) { _valueTypeDesc = ClassUtil.nameOf(valueType); _valueClass = (valueType == null) ? Object.class : valueType; } public StdValueInstantiator(DeserializationConfig config, JavaType valueType) { _valueTypeDesc = (valueType == null) ? "UNKNOWN TYPE" : valueType.toString(); _valueClass = (valueType == null) ? Object.class : valueType.getRawClass(); } /** * Copy-constructor that sub-classes can use when creating new instances * by fluent-style construction */ protected StdValueInstantiator(StdValueInstantiator src) { _valueTypeDesc = src._valueTypeDesc; _valueClass = src._valueClass; _defaultCreator = src._defaultCreator; _constructorArguments = src._constructorArguments; _withArgsCreator = src._withArgsCreator; _delegateType = src._delegateType; _delegateCreator = src._delegateCreator; _delegateArguments = src._delegateArguments; _arrayDelegateType = src._arrayDelegateType; _arrayDelegateCreator = src._arrayDelegateCreator; _arrayDelegateArguments = src._arrayDelegateArguments; _fromStringCreator = src._fromStringCreator; _fromIntCreator = src._fromIntCreator; _fromLongCreator = src._fromLongCreator; _fromDoubleCreator = src._fromDoubleCreator; _fromBooleanCreator = src._fromBooleanCreator; } /** * Method for setting properties related to instantiating values * from JSON Object. We will choose basically only one approach (out of possible * three), and clear other properties */ public void configureFromObjectSettings(AnnotatedWithParams defaultCreator, AnnotatedWithParams delegateCreator, JavaType delegateType, SettableBeanProperty[] delegateArgs, AnnotatedWithParams withArgsCreator, SettableBeanProperty[] constructorArgs) { _defaultCreator = defaultCreator; _delegateCreator = delegateCreator; _delegateType = delegateType; _delegateArguments = delegateArgs; _withArgsCreator = withArgsCreator; _constructorArguments = constructorArgs; } public void configureFromArraySettings( AnnotatedWithParams arrayDelegateCreator, JavaType array

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> /** * Method that can be called to obtain an instance of <code>TypeIdResolver</code> of * specified type. */ public TypeResolverBuilder<?> typeResolverBuilderInstance(Annotated annotated, Class<? extends TypeResolverBuilder<?>> builderClass) { HandlerInstantiator hi = getHandlerInstantiator(); if (hi != null) { TypeResolverBuilder<?> builder = hi.typeResolverBuilderInstance(this, annotated, builderClass); if (builder != null) { return builder; } } return (TypeResolverBuilder<?>) ClassUtil.createInstance(builderClass, canOverrideAccessModifiers()); } /** * Method that can be called to obtain an instance of <code>TypeIdResolver</code> of * specified type. */ public TypeIdResolver typeIdResolverInstance(Annotated annotated, Class<? extends TypeIdResolver> resolverClass) { HandlerInstantiator hi = getHandlerInstantiator(); if (hi != null) { TypeIdResolver builder = hi.typeIdResolverInstance(this, annotated, resolverClass); if (builder != null) { return builder; } } return (TypeIdResolver) ClassUtil.createInstance(resolverClass, canOverrideAccessModifiers()); } }

JacksonDatabind, 81

<FILEB>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, serClass)) {
<CHANGEE>
<CHANGES>
type = type.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, keyClass)) {
<CHANGEE>
<CHANGES>
keyType = keyType.withStaticTyping();
<CHANGEE>
<CHANGES>
} else if (_primitiveAndWrapper(currRaw, contentClass)) {
<CHANGEE>
<CHANGES>
contentType = contentType.withStaticTyping();
<CHANGEE>
<CHANGES>
if ((valueClass!= null) &&!type.hasRawClass(valueClass)
&&!_primitiveAndWrapper(type, valueClass)) {
<CHANGEE>
<CHANGES>
if ((keyClass!= null)
&&!_primitiveAndWrapper(keyType, keyClass)) {
<CHANGEE>
<CHANGES>
if ((contentClass!= null)
&&!_primitiveAndWrapper(contentType, contentClass)) {
<CHANGEE>
<CHANGES>
}
private boolean _primitiveAndWrapper(Class<?> baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType == ClassUtil.primitiveType(refinement);
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType);
}
return false;
}
private boolean _primitiveAndWrapper(JavaType baseType, Class<?> refinement)
{
if (baseType.isPrimitive()) {
return baseType.hasRawClass(ClassUtil.primitiveType(refinement));
}
if (refinement.isPrimitive()) {
return refinement == ClassUtil.primitiveType(baseType.getRawClass());
}
return false;
<CHANGEE>
<FILEE>
<FILEB> final TypeFactory tf = config.getTypeFactory(); final JsonSerialize jsonSer = _findAnnotation(a, JsonSerialize.class); // Ok: start by refining the main type itself; common to all types final Class<?> serClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.as()); if (serClass != null) { if (type.hasRawClass(serClass)) { // 30-Nov-2015, tatu: As per [databind#1023], need to allow forcing of // static typing this way type = type.withStaticTyping(); } else { Class<?> currRaw = type.getRawClass(); try { // 11-Oct-2015, tatu: For deser, we call `TypeFactory.constructSpecializedType()`, // may be needed here too in future? if (serClass.isAssignableFrom(currRaw)) { // common case type = tf.constructGeneralizedType(type, serClass); } else if (currRaw.isAssignableFrom(serClass)) { // specialization, ok as well type = tf.constructSpecializedType(type, serClass); <CHANGES> <CHANGEE> // 27-Apr-2017, tatu: [databind#1592] ignore primitive<->wrapper refinements <CHANGES> <CHANGEE> } else { throw new JsonMappingException(null, String.format("Can not refine serialization type %s into %s; types not related", type, serClass.getName())); } } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to widen type %s with annotation (value %s), from '%s': %s", type, serClass.getName(), a.getName(), iae.getMessage()), iae); } } // Then further processing for container types // First, key type (for Maps, Map-like types): if (type.isMapLikeType()) { JavaType keyType = type.getKeyType(); final Class<?> keyClass = (jsonSer == null) ? null : _classIfExplicit(jsonSer.keyAs()); if (keyClass != null) { if (keyType.hasRawClass(key<SCANS> _location; } @Override public String getCurrentName() { // 25-Jun-2015, tatu: as per [databind#838], needs to be same as ParserBase if (_currToken == JsonToken.START_OBJECT || _currToken == JsonToken.START_ARRAY) { JsonReadContext parent = _parsingContext.getParent(); return parent.getCurrentName(); } return _parsingContext.getCurrentName(); } @Override public void overrideCurrentName(String name) { // Simple, but need to look for START_OBJECT/ARRAY's "off-by-one" thing: JsonReadContext ctxt = _parsingContext; if (_currToken == JsonToken.START_OBJECT || _currToken == JsonToken.START_ARRAY) { ctxt = ctxt.getParent(); } try { ctxt.setCurrentName(name); } catch (IOException e) { throw new RuntimeException(e); } } /* /********************************************************** /* Public API, access to token information, text /********************************************************** */ @Override public String getText() { // common cases first: if (_currToken == JsonToken.VALUE_STRING || _currToken == JsonToken.FIELD_NAME) { Object ob = _currentObject(); if (ob instanceof String) { return (String) ob; } return ClassUtil.nullOrToString(ob); } if (_currToken == null) { return null; } switch (_currToken) { case VALUE_NUMBER_INT: case VALUE_NUMBER_FLOAT: return ClassUtil.nullOrToString(_currentObject()); default: return _currToken.asString(); } } @Override public char[] getTextCharacters() { String str = getText(); return (str == null) ? null : str.toCharArray(); } @Override public int getTextLength() { String str = getText(); return (str == null) ? 0 : str.length(); } @Override public int getTextOffset() { return 0; } @Override public boolean hasTextCharacters() { // We never have raw buffer available, so: return false; } /* /********************************************************** /* Public API, access to token